math.numerics
Class Integral

java.lang.Object
  extended by math.numerics.Integral

public final class Integral
extends java.lang.Object

Class Integral defines various integration algorithms. This class cannot be subclassed or instantiated because all methods are static.

Author:
Wolfgang Christian

Method Summary
static double[][] fillArray(Function f, double start, double stop, double tol, double[][] data)
          Fills the given data array with the intgral of the given function.
static double[][] fillArray(Function f, double start, double stop, double tol, int n)
          Fills a data array with the integral of the given function.
static double ode(Function f, double start, double stop, double tol)
           
static double romberg(Function f, double a, double b, int n, double tol)
          Integrates the function using Romberg's algorithm based on Richardson's deferred approach.
static double simpson(Function f, double start, double stop, int n)
          Numerical integration using Simpson's rule.
static double simpson(Function f, double start, double stop, int n, double tol)
          Numerical integration using Simpson's rule.
static double trapezoidal(Function f, double start, double stop, int n, double tol)
          Integrates the function using the trapezoidal method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

trapezoidal

public static double trapezoidal(Function f,
                                 double start,
                                 double stop,
                                 int n,
                                 double tol)
Integrates the function using the trapezoidal method.

Parameters:
f - the function
start - the first ordinate.
stop - the last ordinate.
n - the number of partitions
tol - relative tolerance
Returns:

simpson

public static double simpson(Function f,
                             double start,
                             double stop,
                             int n)
                      throws java.lang.IllegalArgumentException
Numerical integration using Simpson's rule.

Parameters:
f - a function.
start - the first ordinate.
stop - the last ordinate.
n - the number of partitions
the - integral
Throws:
java.lang.IllegalArgumentException

simpson

public static double simpson(Function f,
                             double start,
                             double stop,
                             int n,
                             double tol)
Numerical integration using Simpson's rule.

Parameters:
f - the function
start - the first ordinate.
stop - the last ordinate.
n - minimum number of partitions
tol - relative tolerance
Returns:
the integral

romberg

public static double romberg(Function f,
                             double a,
                             double b,
                             int n,
                             double tol)
Integrates the function using Romberg's algorithm based on Richardson's deferred approach.

Parameters:
f - the function
start -
stop -
tol - tolerance
Returns:
the integral

ode

public static double ode(Function f,
                         double start,
                         double stop,
                         double tol)

fillArray

public static double[][] fillArray(Function f,
                                   double start,
                                   double stop,
                                   double tol,
                                   int n)
Fills a data array with the integral of the given function.

Parameters:
f - Function to be integrated
start - double start of integral
stop - double end of integral
tol - double computation tolerance
n - int number of data points
Returns:
double[][]

fillArray

public static double[][] fillArray(Function f,
                                   double start,
                                   double stop,
                                   double tol,
                                   double[][] data)
Fills the given data array with the intgral of the given function.

Parameters:
f - Function to be integrated
start - double start of integral
stop - double end of integral
tol - double computation tolerance
data - double[][]
Returns:
double[][]