Double precision Romberg integration solver (Template class represents class whose method is to be integrate!). More...
#include <RombIntSolver.h>
Public Member Functions | |
RombIntSolver (double(T::*fce)(double), T *pTemplate) | |
Constructor - sets function to be integrated. More... | |
RombIntSolver (double(T::*fce)(double), T *pTemplate, float eps) | |
Constructor - sets function to be integrated and integration precision. More... | |
~RombIntSolver () | |
Destructor. More... | |
double | Integrate (double endPointA, double endPointB) |
This method returns a definite integral of function fce calculated in interval (a,b) using so-called Romberg algorithm. More... | |
Protected Member Functions | |
double | TrapezRuleInt (int n) |
This method returns a definite integral of function fce in interval (a,b) and is based on classical extended trapezium rule. More... | |
Private Attributes | |
double | _a |
Left integration endpoint. More... | |
double | _b |
Right integration endpoint. More... | |
float | _eps |
Total integration precision (Caution: Don't overestimate this value!) More... | |
int | _nStepsMin |
Minimum number of integration steps permitted (Avoid spurious early convergence!) More... | |
int | _nStepsMax |
Maximum number of integration steps permitted. More... | |
double(T::* | _fce )(double) |
Relative pointer to an integrated function. More... | |
T * | _pTemplate |
Pointer to the template class. More... | |
Double precision Romberg integration solver (Template class represents class whose method is to be integrate!).
The template class doesn't have *.cpp file!
Definition at line 31 of file RombIntSolver.h.
|
inline |
Constructor - sets function to be integrated.
Definition at line 36 of file RombIntSolver.h.
|
inline |
Constructor - sets function to be integrated and integration precision.
Definition at line 41 of file RombIntSolver.h.
|
inline |
Destructor.
Definition at line 46 of file RombIntSolver.h.
double sistrip::RombIntSolver< T >::Integrate | ( | double | endPointA, |
double | endPointB | ||
) |
This method returns a definite integral of function fce calculated in interval (a,b) using so-called Romberg algorithm.
The algorithm exploites a very general idea of Richardson's deffered approach to the limit, where the function is integrated using the trapezium rule first (with h subsequently set to (a-b), (a-b)/2, (a-b)/4) and then the result is extrapolated to the limit. For n=0 (h=(a-b)) it corresponds to m=0; for n=1 (h=(a-b)/2) it corresponds to m=0 and m=1; ..., where m represents the m-th step to the limit (Richardson extrapolation).
Calculation (R(0,0); R(1,0)->R(1,1); R(2,0->R(2,1)->R(2,2)):
R(0,0) = 1/2*(b-a)*(f(a)+f(b)
R(n,0) = 1/2*R(n-1,0) + h*Sum(i=1,2^(n-1)){f(a+(2*i-1)*h)}
R(n,m) ... m-th iteration - achieved precision O(h^(2^(m+1)))
R(n,m) = R(n,m-1) + (R(n,m-1)-R(n-1,m-1))/(4^m-1)
Total relative precision (influenced by maximum number of steps permitted):
epsilon = |R(n,n) - R(n,n-1)|/R(n,n)
For more details see J.Stoer, R.Bulirsch: Introduction to Numerical Analysis, chap. 2 and 3, 3rd ed., and www.nr.com
Definition at line 116 of file RombIntSolver.h.
|
protected |
This method returns a definite integral of function fce in interval (a,b) and is based on classical extended trapezium rule.
Calculation (n-th iteration):
Int(a,b){f(x)*dx} = h/2*[f(a)+f(b)] + h*Sum(i=1,n-1){f(a+i*h)} - O(h^2)
I(n) = 1/2*I(n-1) + h*Sum(i=1,2^(n-1)){f(a+(2*i-1)*h)}
Where n=0 corresponds to h=(a-b), n=1 to h=(a-b)/2 and the error of the aproximation can be derived from Euler-MacLaurin summation formula and is following:
-B2*h^2/2!*(f'(b)-f'(a)) - B4*h^4/4!*(f'''(b)-f'''(a)) - ...
For more details see J.Stoer, R.Bulirsch: Introduction to Numerical Analysis, chap. 2 and 3, 3rd ed., and www.nr.com
Definition at line 163 of file RombIntSolver.h.
|
private |
Left integration endpoint.
Definition at line 98 of file RombIntSolver.h.
|
private |
Right integration endpoint.
Definition at line 99 of file RombIntSolver.h.
|
private |
Total integration precision (Caution: Don't overestimate this value!)
Definition at line 101 of file RombIntSolver.h.
|
private |
Relative pointer to an integrated function.
Definition at line 106 of file RombIntSolver.h.
|
private |
Maximum number of integration steps permitted.
Definition at line 104 of file RombIntSolver.h.
|
private |
Minimum number of integration steps permitted (Avoid spurious early convergence!)
Definition at line 103 of file RombIntSolver.h.
|
private |
Pointer to the template class.
Definition at line 108 of file RombIntSolver.h.