Class FalsePositionRootFinder

  • public class FalsePositionRootFinderextends IterativeMethod

    The false position method (1) for finding roots of functions.

    For example, to find roots for sine, first a Function is defined:

     Function sine = new Function() {    public double evaluate(double x) {        return Math.sin(x);    }} }; 

    Then, a false position root finder is created with the above function:

     FalsePositionRootFinder finder = new FalsePositionRootFinder(sine); 

    Lastly, locating roots is accomplished using the findRoot(double, double) method:

     // find the root between 3 and 4. double pi = finder.findRoot(3.0, 4.0);  // find the root between -1 and 1. double zero = finder.findRoot(-1.0, 1.0); 


    1. Eric W. Weisstein. "Method of False Position." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/MethodofFalsePosition.html

    • Constructor Detail

      • FalsePositionRootFinder

        public FalsePositionRootFinder(Function f)
        Create a root finder for the given function.
        f - the target function.
      • FalsePositionRootFinder

        public FalsePositionRootFinder(Function f,                       int iterations,                       double error)
        Create a root finder for the given function.
        f - the target function.
        iterations - maximum number of iterations.
        error - maximum relative error.
    • Method Detail

      • findRoot

        public double findRoot(double min,              double max)                throws NumericException
        Find a root of the target function that lies in the interval [ min, max].
        min - the lower bound of the search interval.
        max - the upper bound of the search interval.
        a root that lies between min and max, inclusive.
        NumericException - if a root could not be found.
      • getFunction

        public Function getFunction()
        Access the target function.
        the target function.
      • setFunction

        public void setFunction(Function f)
        Modify the target function.
        f - the new target function.

SCaVis 2.2 © jWork.ORG