A routine that generates an arbitrarily-weighted quadrature scheme for Gaussian numerical integration. Written in Fortran 90 and requires the LAPACK linear algebra library.
You wish to approximate the integral:
where xi and wi are the grid points (a.k.a. "abscissae") and weights of the N-point quadrature scheme, respectively. Knowledge of the weighting function g(x) is contained in these arrays. This package generates these abscissae and weights for any given (relatively well-behaved) weighting function g.
An important feature of Gaussian quadrature is spectral accuracy. Instead of the error decreasing as a power of N, it decreases *exponentially with N.
If you wish to use N > 80, quadratic precision is necessary in calculating the quadrature rules (though not necessarily in the rules themselves). To do so, include the flag -freal-r-real-16
if compiling with gfortran. However, if you need this many grid points, you should consider using a different weighting function or an adaptive numerical integration scheme.
- Copy quadpack.f90 and genquad.f90 to your source directory and include the
genquad
module
use genquad, only: get_quadrature_rule
- When building your application, include your LAPACK library when linking. Also, include following in your Makefile:
FFLAGS = -freal-r-real-8
genquad.o : genquad.f90 quadpack.o
gfortran -c $(FFLAGS) genquad.f90
quadpack.o : quadpack.f90
gfortran -c $(FFLAGS) quadpack.f90
- Make sure the weighting function is defined as
external
in the calling routine.
To ensure integrals are acurately estimated and specral accuracy is maintained, you may wish to run the test suite. To do so:
- Update Makefile with the location of your LAPACK library and, if necessary, your fortran compiler.
- Run
make test
See Appendix C of thesis for more details.