cern_gauss Class Template Reference

#include <cern_gauss.h>

Inheritance diagram for cern_gauss:

inte

Detailed Description

template<class param_t, class func_t>
class cern_gauss< param_t, func_t >

Gaussian quadrature (CERNLIB).

For any interval $ (a,b) $, we define $ g_8(a,b) $ and $ g_{16}(a,b) $ to be the 8- and 16-point Gaussian quadrature approximations to

\[ I=\int_a^b f(x)~dx \]

and define

\[ r(a,b)=\frac{|g_{16}(a,b)-g_{8}(a,b)|}{1+g_{16}(a,b)} \]

The function integ() returns $ G $ given by

\[ G=\sum_{i=1}^{k} g_{16}(x_{i-1},x_i) \]

where $ x_0=a $ and $ x_k=b $ and the subdivision points $ x_i $ are given by

\[ x_i=x_{i-1}+\lambda(B-x_{i-1}) \]

where $ \lambda $ is the first number in the sequence $ 1,\frac{1}{2},\frac{1}{4},... $ for which

\[ r(x_{i-1},x_i)<\mathrm{eps}. \]

If, at any stage, the ratio

\[ q=\left| \frac{x_i-x_{i-1}}{b-a} \right| \]

is so small so that $ 1+0.005 q $ is indistinguishable from unity, then the accuracy is required is not reachable and the error handler is called.

Unless there is severe cancellation, inte::tolf may be considered as specifying a bound on the relative error of the integral in the case that $ |I|>1 $ and an absolute error if $ |I|<1 $. More precisely, if $ k $ is the number of subintervals from above, and if

\[ I_{abs} = \int_a^b |f(x)|~dx \]

then

\[ \frac{|G-I|}{I_{abs}+k}<\mathrm{tolf} \]

will nearly always be true when no error is returned. For functions with no singualarities in the interval, the accuracy will usually be higher than this.

Definition at line 84 of file cern_gauss.h.


Public Member Functions

virtual int integ_err (func_t &func, double a, double b, param_t &pa, double &res, double &err)
 Integrate function func from a to b giving result res and error err.
virtual double integ (func_t &func, double a, double b, param_t &pa)
 Integrate function func from a to b.

Protected Attributes

Integration constants
double x [12]
double w [12]

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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page