Class RootFinder

    • Field Detail

      • xNeg

        protected double xNeg
        Value at which the function's value is negative.
      • xPos

        protected double xPos
        Value at which the function's value is positive.
      • fNeg

        protected double fNeg
        The value of the function at xNeg
      • fPos

        protected double fPos
        The value of the function at xPos
      • myInterval

        protected Interval myInterval
        The interval for the search
      • myInitialPt

        protected double myInitialPt
        The initial point for the search
      • numIterations

        protected static int numIterations
        Used in the static methods for finding intervals
      • searchFactor

        protected static double searchFactor
        used in the static methods for finding intervals
    • Constructor Detail

      • RootFinder

        public RootFinder()
      • RootFinder

        public RootFinder​(FunctionIfc func,
                          double xLower,
                          double xUpper)
    • Method Detail

      • toString

        public java.lang.String toString()
        Returns a String representation of the finder
        Overrides:
        toString in class java.lang.Object
        Returns:
        A String with basic results
      • hasRoot

        public final boolean hasRoot​(Interval interval)
        Returns true if the supplied interval contains a root
        Parameters:
        interval -
        Returns:
      • hasRoot

        public boolean hasRoot​(double xLower,
                               double xUpper)
        Returns true if the supplied interval contains a root
        Parameters:
        xLower -
        xUpper -
        Returns:
      • hasRoot

        public static boolean hasRoot​(FunctionIfc func,
                                      double xLower,
                                      double xUpper)
        Returns true if the supplied interval contains a root
        Parameters:
        func -
        xLower -
        xUpper -
        Returns:
      • findInterval

        public static boolean findInterval​(FunctionIfc func,
                                           Interval interval)
        Using the supplied function and the initial interval provided, try to find a bracketing interval by expanding the interval outward
        Parameters:
        func -
        interval -
        Returns:
      • findInterval

        public static java.util.List<Interval> findInterval​(FunctionIfc func,
                                                            Interval interval,
                                                            int n,
                                                            int nmax)
        Given a function and a starting interval, subdivide the interval into n subintervals and attempt to find nmax bracketing intervals that contain roots
        Parameters:
        func -
        interval -
        n -
        nmax -
        Returns:
        The list of bracketing intervals
      • setInterval

        public final void setInterval​(Interval interval)
        Sets the search interval for the search
        Parameters:
        interval -
      • setInterval

        public void setInterval​(double xLower,
                                double xUpper)
        Sets the bracketing interval within which the root should be found. Throws IllegalArgumentExceptons if the lower limit is > upper limit and if the function does not cross the axis within the provided interval.
        Parameters:
        xLower -
        xUpper -
      • setInitialPoint

        public void setInitialPoint​(double initialPt)
        Sets the initial starting point for the search. The starting point must be in the interval defined for the search or an IllegalArgumentException will be thrown.
        Parameters:
        initialPt -
      • contains

        public final boolean contains​(double x)
        Checks to see if the the supplied point is within the search interval
        Parameters:
        x -
        Returns:
      • getLowerLimit

        public final double getLowerLimit()
        The lower limit for the search interval
        Returns:
      • getUpperLimit

        public final double getUpperLimit()
        The upper limit for the search interval
        Returns:
      • setInterval

        public final void setInterval​(FunctionIfc func,
                                      Interval interval)
        Sets the bracketing interval within which the root should be found. Throws IllegalArgumentExceptons if the lower limit is > upper limit and if the function does not cross the axis within the provided interval.
        Parameters:
        func -
        interval -
      • setInterval

        public final void setInterval​(FunctionIfc func,
                                      double xLower,
                                      double xUpper)
        Sets the bracketing interval within which the root should be found. Throws IllegalArgumentExceptons if the lower limit is > upper limit and if the function does not cross the axis within the provided interval.
        Parameters:
        func - Sets the function to be evaluated, must not be null
        xLower -
        xUpper -