JavaView® v2.00.008

jvx.numeric
Class PnRootFinder

java.lang.Object
  |
  +--jvx.numeric.PnRootFinder

public class PnRootFinder
extends java.lang.Object

Find roots of a function in one variable.

Version:
29.09.99, 1.00 revised (kp)
29.09.99, 1.00 created (kp)
Author:
Konrad Polthier

Constructor Summary
PnRootFinder()
           
 
Method Summary
static PdVector findRoots(PuFunction fx, double x1, double x2, int maxRoots)
          Given a function fx on the interval I=[x1,x2] and a subdivision of I into maxRoots equally spaced subintervals, then find those subintervals with zero crossing and compute a root for each subinterval.
static double[] zbrac(PuFunction fx, double x1, double x2)
          Given a function fx and initial interval I=[x1,x2], then the method expands the range until a root is bracketed by the returned array.
static int zbrak(PuFunction fx, double x1, double x2, int len, double[] xb1, double[] xb2, int nb)
          Given a function fx on the interval I=[x1,x2] and a subdivision of I into len equally spaced subintervals, then find those subintervals with zero crossing and return them as array brackets.
static double zbrent(PuFunction fx, double x1, double x2, double tol)
          Given a function fx find a root known to lie in the interval I=[x1,x2].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PnRootFinder

public PnRootFinder()
Method Detail

findRoots

public static PdVector findRoots(PuFunction fx,
                                 double x1,
                                 double x2,
                                 int maxRoots)
Given a function fx on the interval I=[x1,x2] and a subdivision of I into maxRoots equally spaced subintervals, then find those subintervals with zero crossing and compute a root for each subinterval.

Method uses zbrak to find subintervals with zero crossings, and use zbrent to compute the root on each subinterval which is known to contain a root.

Parameters:
fx - Function to evaluate for zero crossings.
x1, - x2 Original interval.
maxRoots - Number of subintervals to in which to divide interval [x1,x2].
Returns:
Vector with roots, at most one root per subinterval.
See Also:
zbrak(jv.function.PuFunction, double, double, int, double[], double[], int), zbrent(jv.function.PuFunction, double, double, double), PjRootFinder

zbrac

public static double[] zbrac(PuFunction fx,
                             double x1,
                             double x2)
Given a function fx and initial interval I=[x1,x2], then the method expands the range until a root is bracketed by the returned array.
Parameters:
fx - Function to evaluate for zero crossings.
x1, - x2 Original interval.
Returns:
Array with bracketing values, or null if maximal num of tries exceeded.
See Also:
zbrak(jv.function.PuFunction, double, double, int, double[], double[], int)

zbrak

public static int zbrak(PuFunction fx,
                        double x1,
                        double x2,
                        int len,
                        double[] xb1,
                        double[] xb2,
                        int nb)
Given a function fx on the interval I=[x1,x2] and a subdivision of I into len equally spaced subintervals, then find those subintervals with zero crossing and return them as array brackets.
Parameters:
fx - Function to evaluate for zero crossings.
x1, - x2 Original interval.
len - Number of subintervals to in which to divide interval [x1,x2].
xb1, - xb2 Arrays of size 'len to store the brackets of zero crossings.
nb - Requested maximal number of zero crossings.
Returns:
Number of subintervals found with zero crossings.
See Also:
zbrac(jv.function.PuFunction, double, double)

zbrent

public static double zbrent(PuFunction fx,
                            double x1,
                            double x2,
                            double tol)
Given a function fx find a root known to lie in the interval I=[x1,x2]. Root is computed up to requested precision using Brent's method for root finding. Root is returned.
Parameters:
fx - Function to evaluate.
x1, - x2 Interval containing a root of fx.
tol - Required precision.
Returns:
double Root, if found, otherwise return x1-1.
See Also:
zbrac(jv.function.PuFunction, double, double)

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.