Documentation API of the 'jhplot.math.num.root.SecantRootFinder' Java class
SecantRootFinder
jhplot.math.num.root

Class SecantRootFinder



  • public class SecantRootFinderextends IterativeMethod

    The secant 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 secant root finder is created with the above function:

     SecantRootFinder finder = new SecantRootFinder(sine); 

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

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

    References:

    1. Eric W. Weisstein. "Secant Method." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/SecantMethod.html

    • Constructor Detail

      • SecantRootFinder

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

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

      • findRoot

        public double findRoot(double x0,              double x1)                throws NumericException
        Find a root of the target function that lies around the two initial approximations, x0 and x1.
        Parameters:
        x0 - an initial approximation to the root.
        x1 - another initial approximation to the root.
        Returns:
        a root that lies close to x0 and x1.
        Throws:
        NumericException - if a root could not be found.
      • getFunction

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

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

SCaVis 2.2 © jWork.ORG

Warning: You see this message because an access to the SCaVis documentation for third-party Java classes is denied. Guests can only view jhplot Java API. To enable the description of all Java classes of SCaVis, please request the full SCaVis membership.

If you are already a full member, please login to the SCaVis member area before visiting this documentation.