SciLib.Math
Class nonLinear

java.lang.Object
  extended by SciLib.Math.nonLinear

public final class nonLinear
extends java.lang.Object

This class contains some nolinear methods


Constructor Summary
nonLinear()
           
 
Method Summary
static double bisect(Function f, double a, double b, double epsi)
          Bisection method for solving nonlinear equation
static double bisect(Function f, double a, double b, int n)
          Bisection method for solving nonlinear equation
static double[] coef(double[] px, double[] py)
          Compute the coefficients by divided difference
static double eval(double[] a, double[] px, int n, double x)
          Compute the value of polynom with Horner's rule
static double lagrangeInterpolation(double[] px, double[] py, double x)
          Interpoaltion by Lagrange method
static double newton(Function f, Function deriv, double x, double epsi)
          Newton method for solving nonlinear equation
static double newton(Function f, Function deriv, double x, int n)
          Newton method for solving nonlinear equation
static double richardsonExtrapolation(Function f, double x, double h, int n)
          Compute Derivative of a function f at x by the Richardson Extrapolation method
static double richardsonExtrapolation(Function f, double x, int n)
          Compute the derivative of a function f at x by the Richardson Extrapolation method
static double richardsonExtrapolation2deriv(Function f, double x, double h, int n)
          Compute the second derivative of a function f at x by the Richardson Extrapolation method
static double Romberg(Function f, float a, float b, int n)
          Compute the integration by Romberg method
static double secant(Function f, double a, double b, double epsi)
          Secant method for solving nonlinear equation
static double secant(Function f, double a, double b, int n)
          Secant method for solving nonlinear equation
static double trape(Function f, float a, float b, int n)
          Compute the integration by Trape method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

nonLinear

public nonLinear()
Method Detail

bisect

public static double bisect(Function f,
                            double a,
                            double b,
                            int n)
Bisection method for solving nonlinear equation

Parameters:
f - nonlinear function
a - A double value, the left point
b - A double value, the right point
n - An integer value, the numbers of iteration
Returns:
a double value, the zero of the equation between a and b

bisect

public static double bisect(Function f,
                            double a,
                            double b,
                            double epsi)
Bisection method for solving nonlinear equation

Parameters:
f - nonlinear function
a - A double value, the left point
b - A double value, the right point
epsi - A double value, the error
Returns:
a double value, the zero of the equation between a and b

newton

public static double newton(Function f,
                            Function deriv,
                            double x,
                            int n)
Newton method for solving nonlinear equation

Parameters:
f - nonlinear function
deriv - a function, the derivative of f
x - A double value, the start point
n - An integer value, the numbers of iteration
Returns:
a double value, A zero of the equation

newton

public static double newton(Function f,
                            Function deriv,
                            double x,
                            double epsi)
Newton method for solving nonlinear equation

Parameters:
f - nonlinear function
deriv - a function, the derivative of f
x - A double value, the start point
epsi - A double value, the error
Returns:
a double value, A zero of the equation

secant

public static double secant(Function f,
                            double a,
                            double b,
                            int n)
Secant method for solving nonlinear equation

Parameters:
f - nonlinear function
a - A double value, the left point
b - A double value, the right point
n - An integer value, the numbers of iteration
Returns:
a double value, the zero of the equation between a and b

secant

public static double secant(Function f,
                            double a,
                            double b,
                            double epsi)
Secant method for solving nonlinear equation

Parameters:
f - nonlinear function
a - A double value, the left point
b - A double value, the right point
epsi - A double value, the error
Returns:
a double value, the zero of the equation between a and b

richardsonExtrapolation

public static double richardsonExtrapolation(Function f,
                                             double x,
                                             double h,
                                             int n)
Compute Derivative of a function f at x by the Richardson Extrapolation method

Parameters:
f - nonlinear function
x - A double value
h - A double value
n - An integer value, the numbers of iteration
Returns:
a double value, the zero of the equation between a and b

richardsonExtrapolation

public static double richardsonExtrapolation(Function f,
                                             double x,
                                             int n)
Compute the derivative of a function f at x by the Richardson Extrapolation method

Parameters:
f - nonlinear function
x - A double value
n - An integer value, the numbers of iteration
Returns:
a double value, the zero of the equation between a and b

richardsonExtrapolation2deriv

public static double richardsonExtrapolation2deriv(Function f,
                                                   double x,
                                                   double h,
                                                   int n)
Compute the second derivative of a function f at x by the Richardson Extrapolation method

Parameters:
f - nonlinear function
x - A double value
h - A double value
n - An integer value, the numbers of iteration
Returns:
a double value, the zero of the equation between a and b

coef

public static double[] coef(double[] px,
                            double[] py)
Compute the coefficients by divided difference


eval

public static double eval(double[] a,
                          double[] px,
                          int n,
                          double x)
Compute the value of polynom with Horner's rule


lagrangeInterpolation

public static double lagrangeInterpolation(double[] px,
                                           double[] py,
                                           double x)
Interpoaltion by Lagrange method


trape

public static double trape(Function f,
                           float a,
                           float b,
                           int n)
Compute the integration by Trape method


Romberg

public static double Romberg(Function f,
                             float a,
                             float b,
                             int n)
Compute the integration by Romberg method