Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
Euclid::MathUtils::SimpsonsRule Class Reference

#include <SimpsonsRule.h>

Public Member Functions

double operator() (const Function &function, double min, double max, int order)
 Integrate a function between min and max using a mesh of 2^order steps. order>=3.
 
double operator() (const Function &function, double min, double max, double previous_value, int order)
 

Static Public Attributes

static const int minimal_order = 3
 

Detailed Description

Implement numerical integration (quadrature) based on the fit of a polynom of degree 3 on 4 successive points. For polynome of degree 3 the integration is exact even at low order. The formula is taken from "Numerical Recipes" (Third edition) W.H.Press, S.A.Teukolsky, A.T. Vetterling & B.P. Flannery. p160 Equ 4.1.14. With a shift in the notation N-1 -> N. As we use N = 2^m where we call m the order. One may compute the approximation at order = m+1 by adding only the missing terms and thus deducting by ~2 the computational cost. Note that at order m there is (2^m)+1 evaluations of the function for the direct case and (2^(m-1))+4 in the case where the result of the previous order is provided.

Definition at line 48 of file SimpsonsRule.h.

Member Function Documentation

◆ operator()() [1/2]

double Euclid::MathUtils::SimpsonsRule::operator() ( const Function function,
double  min,
double  max,
double  previous_value,
int  order 
)

@detail Integrate a function between min and max using a mesh of 2^order steps based on the value at the previous order (order>=4) by adding only the difference between the integrals.

Parameters
functionthe R-valued function to be integrated.
minthe lower bound of the integration domain
maxthe upper bound of the integration domain
orderthe order of the approximation. The mesh used to compute the integration will have 2^order steps.
previous_valueThe value of the integration at the previous order.

Definition at line 52 of file SimpsonsRule.cpp.

◆ operator()() [2/2]

double Euclid::MathUtils::SimpsonsRule::operator() ( const Function function,
double  min,
double  max,
int  order 
)

Integrate a function between min and max using a mesh of 2^order steps. order>=3.

Parameters
functionthe R-valued function to be integrated.
minthe lower bound of the integration domain
maxthe upper bound of the integration domain
orderthe order of the approximation. The mesh used to compute the integration will have 2^order steps.

Definition at line 32 of file SimpsonsRule.cpp.

Member Data Documentation

◆ minimal_order

const int Euclid::MathUtils::SimpsonsRule::minimal_order = 3
static

The documentation for this class was generated from the following files: