MTH 343 · 4.7 Gaussian quadrature

Gaussian Quadrature Lab

Gaussian quadrature lets the nodes move: with n̄ nodes and n̄ weights it integrates every polynomial of degree up to 2n̄ − 1 exactly. The nodes are the roots of the Legendre polynomial Pn̄ on [−1, 1]; any other interval [a, b] is first mapped to [−1, 1].

f(x) =

Use x as the variable. You can write + − * / ^, sin, cos, tan, exp, ln (or log), sqrt, abs, pi, e.

eˣ cos x on [−1, 1] with n̄ = 3 is Example 1 of the textbook and the exercise on the slides; x⁶ − x² sin 2x on [1, 3] is Example 2 (Gauss n̄ = 2 and 3 against Newton–Cotes n = 1 and 2); x² ln x on [1, 1.5] is Exercise 1(a). With n̄ = 2, x³ is integrated exactly but x⁴ is not: the degree of precision is 2n̄ − 1 = 3.

Interval [a, b]

Numbers or expressions such as pi/2 or sqrt(2), or drag the a and b handles on the plot (in the x view).

Exact value —
Gaussian quadrature — Absolute error —
Closed Newton–Cotes — Absolute error —
Open Newton–Cotes — Absolute error —

Area under f on [a, b]

    Curves
    Variable
    Shade

    From [a, b] to [−1, 1]

    Nodes and weights

    Error as the number of nodes grows

    • Gaussian quadrature
    • Closed Newton–Cotes
    • Open Newton–Cotes