Integrates a function.
This header covers the routines for integrating a function.
The routine LALSRombergIntegrate()
performs the integral specified by the structure input
and the result is returned as result
. Any additional parameters (other than the integration variable \(x\)) can be passed as params
. The routine LALSRombergIntegrate()
does not use params
but just passes it to the integrand. The routine LALDRombergIntegrate()
is the same but for double precision.
The following program performs the integral \(\int_0^2F(x)dx\) where \(F(x)=x^4\log(x+\sqrt{x^2+1})\).
This is an implementation of the Romberg integrating function qromb
in Numerical Recipes [22] .
Prototypes | |
REAL8 | XLALREAL8RombergIntegrate (REAL8(*f)(REAL8 x, void *params), void *params, REAL8 xmin, REAL8 xmax, IntegralType type) |
Enumerations | |
enum | IntegralType { ClosedInterval , OpenInterval , SingularLowerLimit , SingularUpperLimit , InfiniteDomainPow , InfiniteDomainExp } |
Type of integral. More... | |
Files | |
file | IntegrateTest.c |
Tests the routines in Header Integrate.h by performing a suite of numerical integrations and checking the accuracy of the results. | |
REAL8 XLALREAL8RombergIntegrate | ( | REAL8(*)(REAL8 x, void *params) | f, |
void * | params, | ||
REAL8 | xmin, | ||
REAL8 | xmax, | ||
IntegralType | type | ||
) |
Definition at line 233 of file Integrate.c.
enum IntegralType |
Type of integral.
The types of integration are the following:
I. ClosedInterval indicates that the integral should be computed on equal-spaced domain intervals including the boundary.
II. OpenInterval indicates that the integral should be computed on intervals of the domain not including the boundary.
III. SingularLowerLimit indicates that the integral should be evaluated on an open interval with a transformation so that a inverse-square-root singularity at the lower limit can be integrated.
IV. SingularUpperLimit is the same as above but for a singularity at the upper limit.
V. InfiniteDomainPow indicates that the integral should be evaluated over an semi-infinite domain—appropriate when both limits have the same sign (though one is very large) and when the integrand vanishes faster than \(x^{-1}\) at infinity.
VI. InfiniteDomainExp indicates that the integral should be evaluated over an infinite domain starting at xmin
and going to infinity (xmax
is ignored)—the integrand should vanish exponentially for large \(x\).
Definition at line 134 of file Integrate.h.