Computing integrals using a Gaussian quadrature
In the next sections, we will look at how to compute integrals in detail.
Getting ready
This recipe can be done by using the following integration equations.
quad
: General-purpose integrationdblquad
: General-purpose double integrationtplquad
: General-purpose triple integrationfixed_quad
: Integratefunc(x)
using Gaussian quadrature of order nquadrature
: Integrate with the given tolerance using Gaussian quadratureromberg
: Integratefunc
using Romberg integration
How to do it...
There are other possibilities is to use Gaussian quadrature formulas, they are:
- These are more powerful, since the accuracy of the approximations is gained through internally computing the best possible choice of nodes
- There are two basic routines in the
scipy.integrate
module that perform the implementation of this algorithm: quadrature, if we want to specify tolerance, orfixed_quad
, if we wish to specify the number of nodes (but not their locations!):
In [38]: from scipy.integrate...