Gaussian Quadrature

Gaussian quadrature estimates a definite integral as a weighted sum of function values at specially chosen points called nodes. With n nodes it is exact for every polynomial of degree 2n − 1 or less. The two-point rule on [−1, 1] is \int_{-1}^{1} f(t)\,dt \approx f\left(-\tfrac{1}{\sqrt{3}}\right) + f\left(\tfrac{1}{\sqrt{3}}\right).

Before this lesson: Romberg Integration, Simpson’s Rule and U-Substitution with Definite Integrals

The idea: choose the points, not just the weights

The trapezoidal rule, Simpson’s rule and Romberg integration all use equally spaced points fixed in advance, and only the weights are chosen. With n points, such a rule can be made exact for polynomials up to degree about n − 1.

Gaussian quadrature also chooses where the points go. With n points there are 2n numbers to pick (n nodes and n weights), so the rule can match 2n conditions: exactness for 1, t, t², …, t²ⁿ⁻¹. Two well-placed points do the work of Simpson’s rule with three.

The graph shows why. The trapezoidal rule uses the chord through the endpoints, which lies far above y = eᵗ. The two-point Gauss rule uses the line through two interior points; it crosses the curve, so the area it adds on one part nearly cancels the area it misses on another.

Graph of y = e^t on [-1, 1]. The trapezoidal rule uses the chord through (-1, 0.368) and (1, 2.718), which lies well above the curve and gives 3.086. Two-point Gaussian quadrature uses the points t = -0.577 and t = 0.577, where the curve is 0.561 and 1.781; the line through them crosses the curve twice and gives 2.343, close to the exact value 2.350.
On [−1, 1], the trapezoidal rule gives 3.086 for the integral of eᵗ, while two-point Gaussian quadrature gives 2.343 (exact: 2.350).

Gaussian quadrature formula

On the standard interval [−1, 1], the n-point Gauss-Legendre rule is

\int_{-1}^{1} f(t)\,dt \approx \sum_{i=1}^{n} w_i f(t_i)

where the nodes tᵢ are the roots of the Legendre polynomial of degree n and the weights wᵢ are fixed numbers. The rule is exact for every polynomial of degree 2n − 1 or less.

nNodes t_iWeights w_iExact up to degree
1021
2\pm \dfrac{1}{\sqrt{3}} \approx \pm 0.5773501,\ 13
30,\ \pm\sqrt{0.6} \approx \pm 0.774597\dfrac{8}{9},\ \dfrac{5}{9},\ \dfrac{5}{9}5

Changing the interval

For an integral over [a, b], substitute x = [(b − a)/2]t + (a + b)/2, so dx = [(b − a)/2] dt and t runs from −1 to 1 (see u-substitution with definite integrals):

\int_a^b f(x)\,dx \approx \dfrac{b-a}{2}\sum_{i=1}^{n} w_i\, f\left(\dfrac{b-a}{2}t_i + \dfrac{a+b}{2}\right)

How to use Gaussian quadrature

  1. Choose the number of nodes n and look up tᵢ and wᵢ in the table.
  2. Map each node to [a, b] with xᵢ = [(b − a)/2]tᵢ + (a + b)/2.
  3. Evaluate f(xᵢ) and form the weighted sum Σ wᵢ f(xᵢ).
  4. Multiply by (b − a)/2.
  5. To check accuracy, repeat with n + 1 nodes and compare.

Gaussian quadrature examples

Example 1: Finding the two-point nodes and weights

Find t₁, t₂, w₁ and w₂ so that w₁f(t₁) + w₂f(t₂) gives the exact integral over [−1, 1] for f = 1, t, t² and t³.

w_1 + w_2 = 2,\quad w_1t_1 + w_2t_2 = 0

Exact for f = 1 (integral 2) and f = t (integral 0).

w_1t_1^2 + w_2t_2^2 = \dfrac{2}{3},\quad w_1t_1^3 + w_2t_2^3 = 0

Exact for f = t² (integral 2/3) and f = t³ (integral 0).

t_1 = -c,\quad t_2 = c,\quad w_1 = w_2 = w

Try nodes placed symmetrically about 0 with equal weights.

w(-c) + wc = 0,\quad w(-c)^3 + wc^3 = 0

The two odd equations now hold for any c.

2w = 2,\quad w = 1

From the first equation.

2c^2 = \dfrac{2}{3},\quad c^2 = \dfrac{1}{3}

From the t² equation with w = 1.

c = \dfrac{1}{\sqrt{3}} \approx 0.577350

Take the positive square root (see rationalizing the denominator: 1/√3 = √3/3).

Answer: t = ±1/√3 and w₁ = w₂ = 1. Four equations fixed four unknowns, so the rule is exact through degree 3.

Example 2: Exact for a cubic

Use the two-point rule on \int_{-1}^{1} (t^3 + 3t^2 + 1)\,dt and compare with the exact value.

\left[\dfrac{t^4}{4} + t^3 + t\right]_{-1}^{1} = \left(\dfrac{1}{4} + 1 + 1\right) - \left(\dfrac{1}{4} - 1 - 1\right) = 4

Exact value (see fundamental theorem of calculus).

f(c) = c^3 + 3c^2 + 1,\quad f(-c) = -c^3 + 3c^2 + 1

Write the two function values with c = 1/√3.

f(c) + f(-c) = 6c^2 + 2

Add; the c³ terms cancel.

6\left(\dfrac{1}{3}\right) + 2 = 4

Substitute c² = 1/3.

Answer: the rule gives 4, the exact value, with only two function values. Simpson’s rule also gives 4 here, but it needs three.

Example 3: Changing the interval

Estimate \int_0^1 e^x\,dx = e - 1 \approx 1.718282 with the two-point rule, and compare with Simpson’s rule, which uses three points.

x = 0.5t + 0.5,\quad dx = 0.5\,dt

Map [−1, 1] to [0, 1]: (b − a)/2 = 0.5 and (a + b)/2 = 0.5.

x_1 = 0.5 - 0.5(0.577350) = 0.211325,\quad x_2 = 0.5 + 0.288675 = 0.788675

Map the nodes ∓ 0.577350.

e^{0.211325} \approx 1.235314,\quad e^{0.788675} \approx 2.200479

Evaluate f at the nodes.

0.5(1.235314 + 2.200479) = 0.5(3.435793) \approx 1.717897

Add, then multiply by (b − a)/2.

1.718282 - 1.717897 = 0.000385

Error of the Gauss estimate.

\dfrac{1}{6}\left(1 + 4e^{0.5} + e\right) \approx 1.718861

Simpson’s rule with h = 0.5: error −0.000579.

Answer: about 1.717897. Two function values gave a smaller error than Simpson’s rule with three.

Example 4: The three-point rule

Estimate \int_0^{\pi} \sin x\,dx = 2 with the three-point rule.

x = \dfrac{\pi}{2}(t + 1),\quad dx = \dfrac{\pi}{2}\,dt

Map [−1, 1] to [0, π].

x_1 = \dfrac{\pi}{2}(1 - \sqrt{0.6}) \approx 0.354063,\quad x_2 = \dfrac{\pi}{2},\quad x_3 \approx 2.787530

Map the nodes −√0.6, 0 and √0.6.

\sin x_1 = \sin x_3 \approx 0.346711,\quad \sin x_2 = 1

The sine graph is symmetric about π/2.

\dfrac{5}{9}(0.346711) + \dfrac{8}{9}(1) + \dfrac{5}{9}(0.346711) = 0.385234 + 0.888889 = 1.274123

Weighted sum.

1.570796(1.274123) \approx 2.001387

Multiply by (b − a)/2 = π/2.

Answer: about 2.001387, with error about 0.0014 from only three sine values. Romberg integration needed five values to reach a similar error (R(2,2) ≈ 1.998571).

Example 5: A normal probability (word problem)

Test scores are normally distributed. The share of scores between the mean and one standard deviation above it is P(0 \le Z \le 1) = \dfrac{1}{\sqrt{2\pi}}\int_0^1 e^{-x^2/2}\,dx (see standard normal distribution). The integrand has no elementary antiderivative. Estimate the probability with the three-point rule.

x_i = 0.5t_i + 0.5:\quad 0.112702,\ 0.5,\ 0.887298

Map the three nodes to [0, 1].

e^{-x_i^2/2}:\quad 0.993669,\ 0.882497,\ 0.674591

Evaluate the integrand at each node.

\dfrac{5}{9}(0.993669 + 0.674591) + \dfrac{8}{9}(0.882497) = 0.926811 + 0.784442 = 1.711253

Weighted sum.

0.5(1.711253) \approx 0.855627

Multiply by (b − a)/2 = 0.5.

\dfrac{0.855627}{\sqrt{2\pi}} \approx 0.855627(0.398942) \approx 0.341346

Divide by √(2π).

Answer: about 0.3413, so about 34.1% of scores lie between the mean and one standard deviation above it. This matches the normal table value 0.3413 to four decimal places.

Common mistakes

MistakeExample of the errorFix
Forgetting the factor (b − a)/2Reporting 3.435793 for the integral of eˣ on [0, 1]Multiply the weighted sum by (b − a)/2 = 0.5.
Using the [−1, 1] nodes on [a, b] without mappingEvaluating eˣ at x = ±0.577 for an integral on [0, 1]Use xᵢ = [(b − a)/2]tᵢ + (a + b)/2.
Mixing up the three-point weightsGiving the center node weight 5/9The center node gets 8/9 and the outer nodes get 5/9; the weights add to 2.
Expecting exactness one degree too highExpecting the two-point rule to be exact for t⁴n nodes are exact only through degree 2n − 1.
Using Gaussian quadrature on equally spaced dataTrying to apply it to readings taken every secondGauss needs f at the irrational nodes; use the trapezoidal rule, Simpson’s rule or Romberg for tables.

Related methods

Composite Gaussian quadrature

For a long interval or a function that changes quickly, split [a, b] into pieces and apply a two- or three-point rule on each piece. This is like the composite trapezoidal rule, but each piece is much more accurate.

Other Gaussian rules

Gauss-Legendre rules use the weight 1 on [−1, 1]. Other families build a weight function into the rule: Gauss-Chebyshev for 1/√(1 − t²), Gauss-Laguerre for e⁻ˣ on [0, ∞) and Gauss-Hermite for e⁻ˣ² on (−∞, ∞). They handle some improper integrals directly.

Practice problems

  1. Use the two-point rule on \int_{-1}^{1} t^2\,dt. Is the result exact?
  2. Use the two-point rule on \int_{-1}^{1} t^4\,dt and compare with the exact value 2/5.
  3. Use the one-point rule on \int_{-1}^{1} (2t + 5)\,dt.
  4. Use the two-point rule on \int_2^4 x^3\,dx and show that it is exact.
  5. Estimate \int_0^1 \dfrac{1}{1 + x}\,dx = \ln 2 with the two-point rule.
  6. Use the three-point rule on \int_{-1}^{1} t^4\,dt.
  7. What is the highest polynomial degree a four-point Gauss-Legendre rule integrates exactly?
  8. Find the two-point Gauss nodes for an integral over [0, 2].
  9. A solar panel’s power output is P(t) = 5 sin(πt/12) kW for 0 ≤ t ≤ 12 hours. Estimate the energy produced, \int_0^{12} P(t)\,dt, with the two-point rule.
  10. Why is Gaussian quadrature a poor fit for a table of readings taken every minute?
Show answers

1.

\left(-\dfrac{1}{\sqrt{3}}\right)^2 + \left(\dfrac{1}{\sqrt{3}}\right)^2 = \dfrac{1}{3} + \dfrac{1}{3} = \dfrac{2}{3}

Weights are 1.

Answer: 2/3, which is exact (degree 2 ≤ 3)

2.

\dfrac{1}{9} + \dfrac{1}{9} = \dfrac{2}{9} \approx 0.222222

(1/√3)⁴ = 1/9 at each node.

\dfrac{2}{5} - \dfrac{2}{9} = \dfrac{18 - 10}{45} = \dfrac{8}{45}

Error.

Answer: 2/9, off by 8/45 ≈ 0.178, because degree 4 is above 2n − 1 = 3

3.

2 \cdot f(0) = 2(5) = 10

One node at 0 with weight 2.

Answer: 10, exact for this linear function

4.

x = t + 3,\quad dx = dt

(b − a)/2 = 1 and (a + b)/2 = 3.

(3 - c)^3 + (3 + c)^3 = 54 + 18c^2

Expand both cubes with c = 1/√3; the odd powers of c cancel.

54 + 18\left(\dfrac{1}{3}\right) = 60

Substitute c² = 1/3.

\left[\dfrac{x^4}{4}\right]_2^4 = 64 - 4 = 60

Exact value.

Answer: 60, exact, since x³ has degree 3

5.

\dfrac{1}{1.211325} \approx 0.825542,\quad \dfrac{1}{1.788675} \approx 0.559073

Nodes 0.211325 and 0.788675, as in Example 3.

0.5(0.825542 + 0.559073) = 0.5(1.384615) \approx 0.692308

Add, then multiply by 0.5.

Answer: about 0.692308 (ln 2 ≈ 0.693147, error about 0.00084)

6.

\dfrac{5}{9}(0.6)^2 + \dfrac{8}{9}(0) + \dfrac{5}{9}(0.6)^2

(±√0.6)⁴ = 0.36.

= \dfrac{10}{9}(0.36) = 0.4

Add.

Answer: 0.4 = 2/5, exact (degree 4 ≤ 5)

7.

2(4) - 1 = 7

Use 2n − 1 with n = 4.

Answer: degree 7

8.

x = t + 1

(b − a)/2 = 1 and (a + b)/2 = 1.

1 \pm 0.577350

Map ±1/√3.

Answer: x ≈ 0.422650 and x ≈ 1.577350

9.

t = 6s + 6,\quad dt = 6\,ds

Map [−1, 1] to [0, 12].

t = 6 \mp 6(0.577350) \approx 2.535898,\ 9.464102

Map the nodes.

\sin\dfrac{\pi(6 - 2\sqrt{3})}{12} \approx 0.616191 = \sin\dfrac{\pi(6 + 2\sqrt{3})}{12}

Evaluate the sine at both nodes, using 6/√3 = 2√3 (symmetric about t = 6).

6 \cdot 5(0.616191 + 0.616191) = 30(1.232382) \approx 36.97

Multiply by 5 kW and by (b − a)/2 = 6.

Answer: about 37.0 kWh (exact: 120/π ≈ 38.2 kWh); the three-point rule would do much better

10.

Answer: the Gauss nodes are irrational points such as ±0.577350 on the mapped interval, so the needed values are not in the table; equally spaced data call for the trapezoidal rule, Simpson’s rule or Romberg integration

Gaussian quadrature FAQ

What is Gaussian quadrature?

It is a numerical integration method that picks both the evaluation points and their weights so that the rule is exact for polynomials of the highest possible degree, 2n − 1 for n points.

What are the nodes and weights for two-point Gaussian quadrature?

On [−1, 1], the nodes are ±1/√3 ≈ ±0.577350 and both weights are 1. For [a, b], map the nodes with x = [(b − a)/2]t + (a + b)/2 and multiply the sum by (b − a)/2.

Why is Gaussian quadrature more accurate than Simpson’s rule?

Simpson’s rule fixes its points at equal spacing, so three points are exact only through degree 3. Gaussian quadrature also optimizes the point locations, so two points are already exact through degree 3 and three points through degree 5.

What are the nodes of Gauss-Legendre quadrature?

They are the roots of the Legendre polynomial of degree n. For n = 2 that polynomial is (3t² − 1)/2, with roots ±1/√3; for n = 3 it is (5t³ − 3t)/2, with roots 0 and ±√0.6.

Summary

  • Gaussian quadrature chooses n nodes and n weights, so it is exact for polynomials of degree 2n − 1 or less.
  • Two-point rule on [−1, 1]: nodes ±1/√3, weights 1, 1.
  • Three-point rule: nodes 0, ±√0.6, weights 8/9, 5/9, 5/9.
  • For [a, b], use x = [(b − a)/2]t + (a + b)/2 and multiply the sum by (b − a)/2.
  • Use it when f can be evaluated anywhere; use equally spaced rules for tables of data.

Previous lesson: Romberg Integration

Next lesson: Partial Pivoting

Back to the Numerical Methods Index