mmc
Class Integral

java.lang.Object
  extended by mmc.MathModel
      extended by mmc.Integral

public class Integral
extends MathModel

This class provides routines for function integration using Romberg method. Include the function to be integrated in a class that implements the interface FunctionOfx (defined below). Methods contained here are based on the Numerical Recipes (W. H. Press et al.) with the following modifications:

It is possible to evaluate x(rand) such that the integral from xmin to x(rand) is a fraction rand of the original full integral from xmin to xmax. Set the ratio 0<rand<1 as the last argument of one of the open integration methods (integrateOpened or integrateWithSubstitution), and get x(rand) by the subsequent call to getUpperLimit. If rand<0, then -rand is assumed to be the absolute value of the portion of the original integral such that the integral from xmin to x(rand) is equal to this portion. Its sign is determined as the sign of the whole integral (or, rather, the N-1st approximation to its value). If rand is given, it is generally assumed that the function does not change sign on the integration interval. Otherwise, the resulting x(rand) is less predictable. In any case, an approximation to x(rand) is found during evaluation of the original integral, and then refined by the combination of the Newton-Raphson method and bisection.
 interface FunctionOfx{
     double function(double x);
 }
 


Field Summary
 
Fields inherited from class mmc.MathModel
computerPrecision
 
Constructor Summary
Integral()
          initializes class with default settings
Integral(int romberg, int maxSteps, double precision)
          initializes class - this is the main constructor
 
Method Summary
 double getUpperLimit()
          refines and returns the value of the upper limit x(rand)
 double integrateClosed(double min, double max, FunctionOfx function2use)
          finds integral for closed intervals
 double integrateOpened(double min, double max, FunctionOfx function2use)
          finds integral for opened intervals
 double integrateOpened(double min, double max, FunctionOfx function2use, double randomRatio)
          finds integral for opened intervals and computes the value of the x(rand)
 double integrateWithLog(double min, double max, FunctionOfx function2use)
          finds integral for opened intervals using log substitution
 double integrateWithLog(double min, double max, FunctionOfx function2use, double randomRatio)
          finds integral for opened intervals and computes the value of the x(rand)
 double integrateWithLogSubstitution(double min, double max, FunctionOfx function2use, double powerOfSubstitution)
          finds integral for opened intervals using substitution x -> 1/log(x)^(powerOfSubstitution)
 double integrateWithSubstitution(double min, double max, FunctionOfx function2use, double powerOfSubstitution)
          finds integral for opened intervals using substitution x -> 1/x^(powerOfSubstitution)
 double integrateWithSubstitution(double min, double max, FunctionOfx function2use, double powerOfSubstitution, double randomRatio)
          finds integral for opened intervals using substitution x -> 1/x^(powerOfSubstitution) and computes the value of the x(rand)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Integral

public Integral()
initializes class with default settings


Integral

public Integral(int romberg,
                int maxSteps,
                double precision)
initializes class - this is the main constructor

Method Detail

integrateClosed

public double integrateClosed(double min,
                              double max,
                              FunctionOfx function2use)
finds integral for closed intervals


integrateOpened

public double integrateOpened(double min,
                              double max,
                              FunctionOfx function2use)
finds integral for opened intervals


integrateOpened

public double integrateOpened(double min,
                              double max,
                              FunctionOfx function2use,
                              double randomRatio)
finds integral for opened intervals and computes the value of the x(rand)


integrateWithSubstitution

public double integrateWithSubstitution(double min,
                                        double max,
                                        FunctionOfx function2use,
                                        double powerOfSubstitution)
finds integral for opened intervals using substitution x -> 1/x^(powerOfSubstitution)


integrateWithSubstitution

public double integrateWithSubstitution(double min,
                                        double max,
                                        FunctionOfx function2use,
                                        double powerOfSubstitution,
                                        double randomRatio)
finds integral for opened intervals using substitution x -> 1/x^(powerOfSubstitution) and computes the value of the x(rand)


getUpperLimit

public double getUpperLimit()
refines and returns the value of the upper limit x(rand)


integrateWithLog

public double integrateWithLog(double min,
                               double max,
                               FunctionOfx function2use)
finds integral for opened intervals using log substitution


integrateWithLog

public double integrateWithLog(double min,
                               double max,
                               FunctionOfx function2use,
                               double randomRatio)
finds integral for opened intervals and computes the value of the x(rand)


integrateWithLogSubstitution

public double integrateWithLogSubstitution(double min,
                                           double max,
                                           FunctionOfx function2use,
                                           double powerOfSubstitution)
finds integral for opened intervals using substitution x -> 1/log(x)^(powerOfSubstitution)