Calculator · Engineering Mathematics

Gaussian Quadrature Calculator

Approximate a definite integral with an m-point Gauss-Legendre rule mapped from [-1, 1] onto [a, b]. With nodes and weights both chosen optimally, m evaluations integrate any polynomial of degree up to 2m − 1 exactly.

Problem definition

Operators + − * / ^, parentheses, pi and e, and sin, cos, tan, asin, acos, atan, exp, sqrt, abs, ln, log, log10. Write 2*x, not 2x.

Order m (number of points)

Results

Integral estimate Q2.00000011
Interval [a, b][0, 3.142]
Order m (points)5
Function evaluations5
Exact for polynomials of degree≤ 9

Integrand and nodes

f(x)interval bounds a, bquadrature nodes
f(x) = sin(x) on [0, 3.142]. The 5 Gauss nodes are unevenly spaced and none of them sits on an endpoint.

Nodes and weights

Mapped Gauss-Legendre nodes; the weight column already includes the (b − a)/2 factor of the transform
ixᵢf(xᵢ)reference weight on [-1, 1]weight wᵢwᵢ·f(xᵢ)
00.14740.14680.23690.37220.05465
10.7250.66310.47860.75180.4985
21.57110.56890.89360.8936
32.4170.66310.47860.75180.4985
42.9940.14680.23690.37220.05465

Continue

Open in Numerical Integration Lab

f(x), the interval and the order continue into the Lab with the Gauss-Legendre sweep enabled and ending at that order. No reference integral is carried over.

Assumptions & validity

  • · The interval is finite and f is finite at every node; a non-finite node value is a reported failure.
  • · The degree-of-exactness statement applies to POLYNOMIALS only. For any other integrand it is an accuracy heuristic, not a guarantee.
  • · Nodes are strictly interior, so a finite integrand with an awkward endpoint is still evaluated — but this is not an improper-integral solver and makes no claim about singular integrands.
  • · Convergence with increasing m is fast for analytic integrands and can be slow when f has a singularity near the interval in the complex plane.
  • · a > b returns the correct negative integral; a = b returns exactly zero without evaluating f.
  • · Orders 2 to 8 only, from tabulated nodes and weights.

Technical reference

Affine map: x(t) = ((b − a) t + (a + b)) / 2, t ∈ [-1, 1]

∫ₐᵇ f(x) dx = ((b − a)/2) ∫₋₁¹ f(x(t)) dt

Gₘ = Σᵢ₌₁ᵐ wᵢ f(xᵢ), with wᵢ = ((b − a)/2) ŵᵢ

Degree of exactness: Gₘ = I for every polynomial of degree ≤ 2m − 1 (mathematically exact; reproduced here up to floating-point arithmetic)

m
number of Gauss points (the order)
tᵢ, ŵᵢ
reference nodes and weights on [-1, 1]
xᵢ, wᵢ
nodes and weights mapped onto [a, b]
Gₘ
the m-point Gauss-Legendre estimate

Gauss rules choose the node POSITIONS as well as the weights, which is why m evaluations buy degree 2m − 1 exactness, against degree 1 for the trapezoidal rule and 3 for Simpson at comparable cost.

The reference nodes are the roots of the degree-m Legendre polynomial. This tool uses explicit tabulated values for orders 2 to 8 rather than generating them at run time.

No node lies on an endpoint, so an integrand that is merely awkward at a or b is still sampled. That property does not make the rule suitable for genuinely singular or improper integrals.

Accuracy for non-polynomial integrands depends on how well f is approximated by polynomials on the interval; an analytic f converges extremely fast with m, while a kinked f barely improves.

Because there is no subdivision, refinement here means raising m, not shrinking a step. Beyond order 8 the right move is usually to split the interval instead.

The mapped weights sum to b − a mathematically — the rule integrating a constant correctly — up to floating-point rounding in the implementation, which makes the weight column a useful sanity check on the node table.

Related tools