All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----jnt.nonlinear.ZeroFinder
{ int status; double x = -5.0, y = 11.0;
myFunction f = new myFunction(); ZeroFinder zeroin = new ZeroFinder(f);
Tuple interval = new Tuple(x,y);
status = zeroin.search( interval );
System.out.println( "Return code = " + status); System.out.println( "Final interval is " + interval ); System.out.println(" Best estimate of solution is " + interval.x ); System.out.println(" Residual = " + f.eval(interval.x) ); }
class myFunction implements UnivariateFunction { public double eval( double x) { return x*x*x - 1.0; } }
interval (jnt.Tuple)
On input:
Defines the interval [b, c] in which the zero is to be
found.
On output:
[b, c] is reduced so that the zero lies in the interval and
the stopping criterion holds. The left value usually is a
better approximation to the zero than the right value.
Note that it is not necessary for left < right.
relativeErrorTol (double)
Relative error tolerance used in the stopping criterion (see search
method). If the requested value is less than machine precision, then
relativeErrorTol is reset to approximately machine precision.
absoluteErrorTol (double)
Absolute error tolerance used in the stopping criterion (see search
method). If search intervals will contain the origin, then a
nonzero value should be chosen.
maxIterations (int)
The maximum number of iterations to be used in the search procedure.
return value (int)
a status code indicating which of the following conditions hold.
Let [b,c] == [interval.x,interval.y].
A - |b-c| <= 2.*(relativeErrorTol*|b|+absoluteErrorTol) B - f(b) * f(c) < 0. C - |f(b)| <= |f(c)| D - |f(bout)| <= max(|(f(bin)|,|f(cin)|) E - number of evaluations of f(x) <= maxIterations
Return Value |
Interpretation |
1 | indicates normal case. All conditions above hold. |
2 | indicates f(b) = 0. Condition A may not hold. |
3 | indicates conditions A, B, C, and E hold but D does not. [b,c] probably contains a singular point of f. |
4 | indicates conditions A and E hold but B does not. A local minimum of f(x) in [b,c] may have been found. |
5 | indicates search was aborted when condition E failed. |
This class is based on the Fortran subroutine ZEROIN, originally developed by
public ZeroFinder(UnivariateFunction f)
class myFunction implements UnivariateFunction { public double eval( double x) { return x*x*x - 1.0; } }
public int search(Tuple interval)
The search concludes when the width of the given interval [b,c] has collapsed to within a tolerance specified by the stopping criterion, |b-c| <= 2.*(relativeErrorTol*|b| + absoluteErrorTol). The following defaults are used: relativeErrorTol = 1.0e-8, absoluteErrorTol = 1.0e-8, maxIterations = 500.
public int search(Tuple interval, double relativeErrorTol)
The search concludes when the width of the given interval [b,c] has collapsed to within a tolerance specified by the stopping criterion, |b-c| <= 2.*(relativeErrorTol*|b| + absoluteErrorTol). The following defaults are used: absoluteErrorTol = relativeErrorTol, maxIterations = 500.
public int search(Tuple interval, double relativeErrorTol, double absoluteErrorTol)
The search concludes when the width of the given interval [b,c] has collapsed to within a tolerance specified by the stopping criterion, |b-c| <= 2.*(relativeErrorTol*|b| + absoluteErrorTol). The following defaults are used: maxIterations = 500.
public int search(Tuple interval, double relativeErrorTol, double absoluteErrorTol, int maxIterations)
The search concludes when the width of the given interval [b,c] has collapsed to within a tolerance specified by the stopping criterion, |b-c| <= 2.*(relativeErrorTol*|b| + absoluteErrorTol).
All Packages Class Hierarchy This Package Previous Next Index