Gaussian Quadrature Calculator (Gauss-Legendre)
Compute definite integrals with Gauss-Legendre quadrature. Tabulated nodes and weights up to n=10, composite form, and comparison with Simpson's 1/3 rule.
Report a calculation error
Help us improve. Describe what is wrong with the calculation.
Result
| Voce | Valore |
|---|
Show full details
Share result
Disclaimer: this calculation is for informational purposes only. For important decisions, consult a qualified professional.
What Gaussian quadrature is
Gaussian quadrature is a family of numerical-integration methods that approximate a definite integral as a weighted sum of function values at a minimal set of optimally chosen points:
∫ab f(x) dx ≈ ((b−a)/2) · ∑i=1n wi · f(((b−a)/2)·xi + (b+a)/2)
where xi are the nodes and wi the weights, chosen so that the formula is exact for polynomials up to degree 2n−1. This is the key advantage over Newton-Cotes rules (trapezoidal, Simpson), which with the same n+1 nodes achieve at best degree n or n+1.
Gauss-Legendre nodes and weights
The calculator uses Gauss-Legendre, which applies to any integral on [a,b] after the change of variables x = ((b−a)/2)·t + (b+a)/2 mapping to [−1,1]. The nodes xi are the roots of the Legendre polynomial Pn(x), and the weights are:
wi = 2 / [(1−xi²)·(Pn′(xi))²]
Values are tabulated for n = 2, 3, 4, 5, 6, 8, 10 to 16-digit precision (standard Abramowitz-Stegun and Numerical Recipes values).
The four modes
- Gauss-Legendre on [a, b]: integrates f(x) with the n-point rule, showing transformed nodes, effective weights and f values.
- Composite: splits [a, b] into M equal subintervals and applies n-point Gauss-Legendre in each; efficient for non-smooth functions.
- Gauss vs Simpson comparison: computes both and reports |IGauss − ISimpson| as a truncation-error estimate.
- Nodes & weights table: lists official values on [−1, 1] for the chosen n, useful for manual implementation or teaching.
Why it is so accurate
Gauss's 1814 insight was to abandon equispaced nodes and let 2n parameters (n nodes + n weights) be chosen freely. Imposing 2n conditions makes the rule exact on 2n monomials (1, x, …, x2n−1), hence degree of precision 2n−1.
Example: with n = 5, Gauss-Legendre is exact for polynomials up to degree 9. Simpson's rule on the same 5 equispaced points is exact only up to degree 3. For smooth functions, Gaussian quadrature converges exponentially in n, while Simpson converges algebraically as O(h⁴).
Applications
- Finite-element methods: stiffness matrices and load vectors on reference elements. All major codes (ANSYS, Abaqus, COMSOL, FEniCS) use Gauss-Legendre.
- Computational physics: radial integrals in spherical-symmetry problems, atomic Hamiltonians.
- Quantitative finance: option pricing under stochastic-volatility models; characteristic-function integration.
- Adaptive quadrature: Gauss-Kronrod (QUADPACK, SciPy
quad) adds nodes to Gauss-Legendre to estimate error. - Machine learning: posterior-likelihood integration in variational Bayesian methods.
Limits and caveats
- For singular integrands (like 1/√x at 0), use a regularising change of variables or weighted quadratures (Gauss-Chebyshev, Gauss-Jacobi).
- For improper integrals on infinite intervals, use Gauss-Hermite (weight e−x²) or Gauss-Laguerre (weight e−x).
- For high-frequency oscillatory integrands, many nodes are needed; Filon or Levin integration is more efficient.
- For discontinuous functions, Gauss-Legendre loses exponential convergence; adaptive Simpson or domain partitioning is better.
History of Gaussian quadrature
The method was introduced by Carl Friedrich Gauss in 1814: he asked what the optimal choice of evaluation points would be to maximise the accuracy of a numerical integration formula. The answer was surprising: choosing as nodes the roots of the Legendre polynomials and suitable weights, an n-point formula integrates exactly all polynomials up to degree 2n−1, twice what equally spaced nodes would give. Later Carl Gustav Jacobi provided a more elegant proof and generalised the method to other families of orthogonal polynomials. Today Gaussian quadrature is one of the pillars of numerical analysis and scientific computing, from finite element methods to computational physics.
Variants of Gaussian quadrature
The Gauss-Legendre method is only the best known of a family. By changing the weight function in the integral, variants suited to different problems arise: Gauss-Chebyshev quadrature uses the weight 1/√(1−x²), useful for integrands with singularities at the endpoints; Gauss-Hermite integrates over the whole real line with weight e^(−x²), fundamental in quantum mechanics and probability; Gauss-Laguerre integrates over [0, ∞) with weight e^(−x), typical of decay problems and transforms. All share the same principle: nodes as roots of orthogonal polynomials and degree of precision 2n−1, adapted to the domain and the nature of the integrand.
Updated July 2026
Comments (0)
Login to leave a comment.
No comments yet. Be the first!