net.sourceforge.webcompmath.functions
Class ZeroFinder

java.lang.Object
  extended by net.sourceforge.webcompmath.functions.ZeroFinder

public class ZeroFinder
extends java.lang.Object

Description for ZeroFinder
ZeroFinder computes one zero of the continuous function func,
provided that the two starting values x1 and x2 satisfy:
func( x1 ) * func( x2 ) <= 0 .



Applications :

Determine one root of the continuous function func, if an
inclusion interval [x1, x2] is known for the root.


"Return values" :
= -1 No inclusion: func( x2 ) * func( x1 ) >0
= 0 Root has been found with ABS( f2 ) < funcERR
= 1 Break-off with ABS(xnew-xold ) < ABSERR + xnew * RELERR,
check functional value
= 2 Iteration limit reached
= 3 Improper input parameters
= 4 NaN encountered
getSolution() gives the solution if isSolved() returns true.

Constants used : ABSERR, RELERR, MACH_EPS, EPSROOT, ITERMAX


Author:
pkhg

Field Summary
protected  double ABSERROR
          Default value of absolute error bound
protected  double funcERR
           -1: no inclusion given 0: with abs( f( x )) <= Double.Min_Value 1: ABS( xnew-xold ) < ABSERROR + xnew * RELERROR 2: iterationlimit ITERMAX reached 3: improper function 4: NaN encountered at: x3;
protected  Function function
          The function, for which zeros are to be found ( should be continous!)
protected  double fX1in
          Interval ( left ) point
protected  double fX2in
          Interval ( right ) point
protected  int iter
          Iterations used
protected  int ITERMAX
          Default value of maximun number of iterations
protected  double RELERROR
          Default value of relative error bound
protected  java.lang.String resultOfIteration
          Description of kind of soulution
protected  double solution
          Place of a zero ( within precision )
protected  boolean solved
          Solution with given precision found or not
protected static double ZERO
          Description of the Field
 
Constructor Summary
ZeroFinder()
          Default constructor for the ZeroFinder object
ZeroFinder(Function inFunction)
          The object with standard precision parameters
 
Method Summary
 double getAbsError()
          Gets the AbsError attribute of the ZeroFinder object
 double getFX1in()
          Gets the FX1in attribute of the ZeroFinder object
 double getFX2in()
          Gets the FX2in attribute of the ZeroFinder object
 int getIter()
          Gets the Iter attribute of the ZeroFinder object
 int getIterMax()
          Gets the IterMax attribute of the ZeroFinder object
 double getRelError()
          Gets the RelError attribute of the ZeroFinder object
 java.lang.String getResultOfIteration()
          Gets the ResultOfIteration attribute of the ZeroFinder object
 double getSolution()
          Gets the Solution attribute of the ZeroFinder object
 boolean isSolved()
          Gets the Solved attribute of the ZeroFinder object
static void main(java.lang.String[] arg)
          To test ZeroFinder
 void setAbsError(double newAbsError)
          Sets the AbsError attribute of the ZeroFinder object
 void setFunction(Function newFunction)
          Sets the Function attribute of the ZeroFinder object
 void setIterMax(int maxiter)
          Sets the IterMax attribute of the ZeroFinder object
 void setRelError(double newRelError)
          Sets the RelError attribute of the ZeroFinder object
 void Solve(double x1in, double x2in)
          The 'Regula Falsi' extended ZeroFinder zero-finder:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

function

protected Function function
The function, for which zeros are to be found ( should be continous!)


solved

protected boolean solved
Solution with given precision found or not


solution

protected double solution
Place of a zero ( within precision )


fX1in

protected double fX1in
Interval ( left ) point


fX2in

protected double fX2in
Interval ( right ) point


ITERMAX

protected int ITERMAX
Default value of maximun number of iterations


ABSERROR

protected double ABSERROR
Default value of absolute error bound


RELERROR

protected double RELERROR
Default value of relative error bound


resultOfIteration

protected java.lang.String resultOfIteration
Description of kind of soulution


funcERR

protected double funcERR
     
    -1: no inclusion given
    0: with abs( f( x )) <= Double.Min_Value
    1: ABS( xnew-xold ) < ABSERROR + xnew * RELERROR
    2: iterationlimit   ITERMAX   reached
    3: improper function
    4: NaN encountered at:  x3;
  
 


iter

protected int iter
Iterations used


ZERO

protected static double ZERO
Description of the Field

Constructor Detail

ZeroFinder

public ZeroFinder()
Default constructor for the ZeroFinder object


ZeroFinder

public ZeroFinder(Function inFunction)
The object with standard precision parameters

ITERMAX = 20;

ABSERROR = 1.0E-6D;

RELERROR = 1.0E-6D;

funcERR = Double.MIN_VALUE;

Parameters:
inFunction - a Function Object e.g. from TaylorInput
Method Detail

setRelError

public void setRelError(double newRelError)
Sets the RelError attribute of the ZeroFinder object

Parameters:
newRelError - The new RelError value

setAbsError

public void setAbsError(double newAbsError)
Sets the AbsError attribute of the ZeroFinder object

Parameters:
newAbsError - The new AbsError value

setIterMax

public void setIterMax(int maxiter)
Sets the IterMax attribute of the ZeroFinder object

Parameters:
maxiter - The new IterMax value

setFunction

public void setFunction(Function newFunction)
Sets the Function attribute of the ZeroFinder object

Parameters:
newFunction - The new Function value

getSolution

public double getSolution()
Gets the Solution attribute of the ZeroFinder object

Returns:
The Solution value

isSolved

public boolean isSolved()
Gets the Solved attribute of the ZeroFinder object

Returns:
The Solved value

getRelError

public double getRelError()
Gets the RelError attribute of the ZeroFinder object

Returns:
The RelError value

getFX1in

public double getFX1in()
Gets the FX1in attribute of the ZeroFinder object

Returns:
The FX1in value

getFX2in

public double getFX2in()
Gets the FX2in attribute of the ZeroFinder object

Returns:
The FX2in value

getAbsError

public double getAbsError()
Gets the AbsError attribute of the ZeroFinder object

Returns:
The AbsError value

getIter

public int getIter()
Gets the Iter attribute of the ZeroFinder object

Returns:
The Iter value

getIterMax

public int getIterMax()
Gets the IterMax attribute of the ZeroFinder object

Returns:
The IterMax value

getResultOfIteration

public java.lang.String getResultOfIteration()
Gets the ResultOfIteration attribute of the ZeroFinder object

Returns:
The ResultOfIteration value

Solve

public void Solve(double x1in,
                  double x2in)
The 'Regula Falsi' extended ZeroFinder zero-finder:

Parameters:
x1in - left point of interval
x2in - right point of interval

main

public static void main(java.lang.String[] arg)
To test ZeroFinder

Parameters:
arg - ( not used )