Maths & numbers

Gauss–Legendre quadrature calculator with nodes and weights

Estimate a finite-interval integral with 1–64 Gauss–Legendre nodes, mapped weights, contributions and a separate-order comparison.

Your numbers

Use x, arithmetic, powers with ^, sin, cos, exp, log, sqrt or abs. Trigonometric arguments are radians. No JavaScript is evaluated.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Gauss–Legendre quadrature places sample points at roots of a Legendre polynomial rather than on a uniform grid. Carefully chosen weights let an n-node rule integrate every polynomial through degree 2n minus one exactly in real arithmetic. This page maps the canonical rule to your finite interval, evaluates the entered function and exposes each weighted contribution. It also compares a second node count, making numerical agreement visible without claiming that it proves accuracy for every function.

THE FORMULA∫aᵇ f(x)dx ≈ (b−a)/2 Σwᵢ f((a+b)/2 + (b−a)tᵢ/2), where Pn(tᵢ)=0.

A worked example

Integrate x⁴ from −1 to 1 using three nodes. The nodes are 0 and ±√(3/5), with weights 8/9 and 5/9. The center contributes zero and the outer terms sum to 2/5. This agrees with the antiderivative x⁵/5 and falls within the three-node rule’s polynomial exactness range.

Good to know

Bounds must increase and stay within ±1,000,000. The rule supports 1–64 nodes and finite sampled function values within ±10¹². Fixed-order quadrature can miss unsampled spikes, oscillations or singularities. This is not an improper-integral solver, an automatic singularity detector or a certified error estimator. The comparison uses twice the order up to 64; at order 64 it compares with 32.

Nodes and weights must be transformed together

The standard Legendre rule lives on [−1,1]. To integrate over [a,b], shift and stretch every node using the interval midpoint and half-width. Multiply every weight by the same half-width. Transforming the sample locations without scaling the weights would give the wrong integral even for a constant function. The mapped weights should sum to b − a, which is a useful basic check.

The table distinguishes canonical nodes from mapped coordinates. It also lists the function value and its contribution after multiplication by the mapped weight. Summing the final column recovers the reported estimate. These details explain why the method uses nonuniform points and make a suspected expression or interval mistake easier to locate.

Three Gauss nodes integrate x to the fourth over minus one to one5/98/95/9−√(3/5)0√(3/5)Weighted sum = 2/5
Canonical nodes are 0 and ±√(3/5). Their weights are 8/9 and 5/9. The two nonzero weighted contributions sum to 2/5.

The Cauchy principal value integral calculator for a simple pole handles a declared polynomial-over-linear singular form, which this quadrature rule does not regularize.

Polynomial exactness has a specific scope

Three nodes integrate x⁴ exactly, but this does not mean that three samples reconstruct an arbitrary function or prove a tiny error for a sharply peaked integrand. The exactness statement concerns a bounded polynomial degree with smooth finite behavior and exact arithmetic. Roundoff remains in the computed roots, weights and function evaluations, so decimal results can differ in their last digits.

A small difference between two orders is evidence of agreement between those samples, not a guaranteed bound on what happened between them. Both rules can miss the same narrow feature. For a familiar uniform-panel comparison, the existing numerical integration calculator provides Simpson and trapezoidal methods. Increasing the Gauss order changes the sampling rule on this page; it does not require publishing a separate calculator for each node count.

A few questions, answered

Are the endpoints sampled?

Gauss–Legendre nodes lie strictly inside the interval. This does not automatically make an endpoint singularity safe or the integral convergent.

Why does one node reproduce the midpoint rule?

The one-node canonical rule has node zero and weight two. After mapping, it evaluates the interval midpoint and multiplies by the interval width.

Find your calculator

Start typing to explore the library.