Exercise: Gauss-Legendre on a general interval

Changing variables from [1,1.5] to [-1,1] and applying Gauss-Legendre with n=2 and n=3.

Transform and sum

ExampleIntegral of e^{-x²}

Compute I=11.5ex2dxI=\int_1^{1.5} e^{-x^2}\,dx with Gauss-Legendre using n=2n=2 and n=3n=3.

  1. Transform [1,1.5] into [-1,1]:

    x=14y+54,dx=14dyx=\frac{1}{4}y+\frac{5}{4},\qquad dx=\frac{1}{4}dy
  2. The integral becomes:

    I=1411e(y+5)2/16dyI=\frac{1}{4}\int_{-1}^{1}e^{-(y+5)^2/16}\,dy
  3. With two nodes, ±0.577350 and weights 1:

    I2=0.109400I_2=0.109400
  4. With three nodes, 0 and ±0.774597, weights 0.888889 and 0.555556:

    I3=0.109364I_3=0.109364

The correct transformation includes the factor 1/4; without it, the result is four times too large.