Public Member Functions | List of all members
o2scl::inte_gauss_cern< func_t > Class Template Reference

Gaussian quadrature (CERNLIB) More...

#include <inte_gauss_cern.h>

Inheritance diagram for o2scl::inte_gauss_cern< func_t >:
o2scl::inte< func_t >

Public Member Functions

virtual int integ_err (func_t &func, double a, double b, double &res, double &err)
 Integrate function func from a to b.
 
- Public Member Functions inherited from o2scl::inte< func_t >
virtual double integ (func_t &func, double a, double b)
 Integrate function func from a to b.
 
double get_error ()
 Return the numerically estimated error in the result from the last call to integ() More...
 
virtual const char * type ()
 Return string denoting type ("inte")
 

Protected Attributes

Integration constants (Set in the constructor)
double x [12]
 
double w [12]
 
- Protected Attributes inherited from o2scl::inte< func_t >
double interror
 The uncertainty for the last integration computation.
 

Additional Inherited Members

- Public Attributes inherited from o2scl::inte< func_t >
int verbose
 Verbosity.
 
size_t last_iter
 The most recent number of iterations taken.
 
double tol_rel
 The maximum relative uncertainty in the value of the integral (default $ 10^{-8} $)
 
double tol_abs
 The maximum absolute uncertainty in the value of the integral (default $ 10^{-8} $)
 
bool err_nonconv
 If true, call the error handler if the routine does not converge or reach the desired tolerance (default true) More...
 

Detailed Description

template<class func_t = funct11>
class o2scl::inte_gauss_cern< func_t >

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::tol_rel 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{tol_rel} \]

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.

If the desired accuracy is not achieved, the integration functions will call the error handler and return the best guess, unless inte::err_nonconv is false, in which case the error handler is not called.

This function is based on the CERNLIB routines GAUSS and DGAUSS which are documented at http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/d103/top.html

Idea for Future:
Allow user to change cst?

Definition at line 96 of file inte_gauss_cern.h.


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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).