physics3d
Class ZeroFinder
java.lang.Object
physics3d.ZeroFinder
public class ZeroFinder
- extends Object
Nested Class Summary |
static interface |
ZeroFinder.Function
ZeroFinder.Function is an interface which specifies a function whose roots
can be found by this class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ZeroFinder
public ZeroFinder()
findRoot
public static double findRoot(ZeroFinder.Function function,
double t_min,
double t_max,
int subintervals)
- Requires:
- t_min <= t_max, stepSize > 0
Searches for possible roots of
function
by looking for sign
changes. If a possible root is found, regula falsi is performed to try to
determine the precise value of the root. This function searches for roots
between t_min
and t_max
. Will return the
smallest zero within the first interval of length stepSize where function
changes sign. If no solution is found returns NaN
, else
returns the solution.
To improve speed, use smaller intervals or increase the step size. However,
increasing the step size also increases the chance that the root you get is
not the smallest. Also increasing the step size could decreases the
probability that a root will be found, as less points are tested.