Documentation of 'jsci.maths.NumericalMath' Java class
NumericalMath
jsci.maths

Class NumericalMath



  • public final class NumericalMath
    extends AbstractMath
    The numerical math library. This class cannot be subclassed or instantiated because all methods are static.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static double bisection(Mapping func, double a, double b, int maxIter, double tol)
      Finds a root using the bisection method.
      static double[] differentiate(int N, Mapping func, double a, double b)
      Numerical differentiation.
      static double[][] differentiate(MappingND func, double[] x, double[] dx)
      Numerical differentiation in multiple dimensions.
      static double[] euler(double[] y, Mapping func, double dt)
      Uses the Euler method to solve an ODE.
      static double falsePosition(Mapping func, double a, double b, int maxIter, double tol)
      Finds a root using the false position method.
      static double gaussian4(int N, Mapping func, double a, double b)
      Numerical integration using the Gaussian integration formula (4 points).
      static double gaussian8(int N, Mapping func, double a, double b)
      Numerical integration using the Gaussian integration formula (8 points).
      static double[] leapFrog(double[] y, Mapping func, double dt)
      Uses the Leap-Frog method to solve an ODE.
      static double[] metropolis(double[] list, Mapping func, double dx)
      The Metropolis algorithm.
      static double newtonRaphson(RealFunction func, double x, int maxIter, double tol)
      Finds a root using the Newton-Raphson method.
      static double richardson(int N, Mapping func, double a, double b)
      Numerical integration using the Richardson extrapolation.
      static double[] rungeKutta2(double[] y, Mapping func, double dt)
      Uses the 2nd order Runge-Kutta method to solve an ODE.
      static double[] rungeKutta2(double[] y, RealFunction2D func, double t0, double dt)
      Uses the 2nd order Runge-Kutta method to solve an ODE.
      static double[] rungeKutta4(double[] y, Mapping func, double dt)
      Uses the 4th order Runge-Kutta method to solve an ODE.
      static double[] rungeKutta4(double[] y, RealFunction2D func, double t0, double dt)
      Uses the 4th order Runge-Kutta method to solve an ODE.
      static double simpson(int N, Mapping func, double a, double b)
      Numerical integration using Simpson's rule.
      static double[] solveQuadratic(double a, double b, double c)
      Calculates the roots of the quadratic equation ax2+bx+c=0.
      static double trapezium(int N, Mapping func, double a, double b)
      Numerical integration using the trapezium rule.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • solveQuadratic

        public static double[] solveQuadratic(double a,
                                              double b,
                                              double c)
        Calculates the roots of the quadratic equation ax2+bx+c=0.
        Returns:
        an array containing the two roots.
      • euler

        public static double[] euler(double[] y,
                                     Mapping func,
                                     double dt)
        Uses the Euler method to solve an ODE.
        Parameters:
        y - an array to be filled with y values, set y[0] to initial condition.
        func - dy/dt as a function of y.
        dt - step size.
        Returns:
        y.
      • leapFrog

        public static double[] leapFrog(double[] y,
                                        Mapping func,
                                        double dt)
        Uses the Leap-Frog method to solve an ODE.
        Parameters:
        y - an array to be filled with y values, set y[0], y[1] to initial conditions.
        func - dy/dt as a function of y.
        dt - step size.
        Returns:
        y.
      • rungeKutta2

        public static double[] rungeKutta2(double[] y,
                                           Mapping func,
                                           double dt)
        Uses the 2nd order Runge-Kutta method to solve an ODE.
        Parameters:
        y - an array to be filled with y values, set y[0] to initial condition.
        func - dy/dt as a function of y.
        dt - step size.
        Returns:
        y.
      • rungeKutta2

        public static double[] rungeKutta2(double[] y,
                                           RealFunction2D func,
                                           double t0,
                                           double dt)
        Uses the 2nd order Runge-Kutta method to solve an ODE.
        Parameters:
        y - an array to be filled with y values, set y[0] to initial condition.
        func - dy/dt as a function of y and t.
        t0 - initial time.
        dt - step size.
        Returns:
        y.
      • rungeKutta4

        public static double[] rungeKutta4(double[] y,
                                           Mapping func,
                                           double dt)
        Uses the 4th order Runge-Kutta method to solve an ODE.
        Parameters:
        y - an array to be filled with y values, set y[0] to initial condition.
        func - dy/dt as a function of y.
        dt - step size.
        Returns:
        y.
      • rungeKutta4

        public static double[] rungeKutta4(double[] y,
                                           RealFunction2D func,
                                           double t0,
                                           double dt)
        Uses the 4th order Runge-Kutta method to solve an ODE.
        Parameters:
        y - an array to be filled with y values, set y[0] to initial condition.
        func - dy/dt as a function of y and t.
        dt - step size.
        Returns:
        y.
      • trapezium

        public static double trapezium(int N,
                                       Mapping func,
                                       double a,
                                       double b)
        Numerical integration using the trapezium rule.
        Parameters:
        N - the number of strips to use.
        func - a function.
        a - the first ordinate.
        b - the last ordinate.
      • simpson

        public static double simpson(int N,
                                     Mapping func,
                                     double a,
                                     double b)
        Numerical integration using Simpson's rule.
        Parameters:
        N - the number of strip pairs to use.
        func - a function.
        a - the first ordinate.
        b - the last ordinate.
      • richardson

        public static double richardson(int N,
                                        Mapping func,
                                        double a,
                                        double b)
        Numerical integration using the Richardson extrapolation.
        Parameters:
        N - the number of strip pairs to use (lower value).
        func - a function.
        a - the first ordinate.
        b - the last ordinate.
      • gaussian4

        public static double gaussian4(int N,
                                       Mapping func,
                                       double a,
                                       double b)
        Numerical integration using the Gaussian integration formula (4 points).
        Parameters:
        N - the number of strips to use.
        func - a function.
        a - the first ordinate.
        b - the last ordinate.
      • gaussian8

        public static double gaussian8(int N,
                                       Mapping func,
                                       double a,
                                       double b)
        Numerical integration using the Gaussian integration formula (8 points).
        Parameters:
        N - the number of strips to use.
        func - a function.
        a - the first ordinate.
        b - the last ordinate.
      • differentiate

        public static double[] differentiate(int N,
                                             Mapping func,
                                             double a,
                                             double b)
        Numerical differentiation.
        Parameters:
        N - the number of points to use.
        func - a function.
        a - the first ordinate.
        b - the last ordinate.
      • differentiate

        public static double[][] differentiate(MappingND func,
                                               double[] x,
                                               double[] dx)
        Numerical differentiation in multiple dimensions.
        Parameters:
        func - a function.
        x - coordinates at which to differentiate about.
        dx - step size.
        Returns:
        an array Mij=dfi/dxj.
      • metropolis

        public static double[] metropolis(double[] list,
                                          Mapping func,
                                          double dx)
        The Metropolis algorithm.
        Parameters:
        list - an array to be filled with values distributed according to func, set list[0] to initial value.
        func - distribution function.
        dx - step size.
        Returns:
        list.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.