Evaluation of a single definite integral using fourth-order Gauss quadrature.
Evaluate \int_{0}^{3} e^{-x^{2}} d x using four-point Gauss quadrature.
Step 1: Since the limits of integration are [0,3], the integral has to be transformed to the form \int_{-1}^{1} f(t) d t. In the present problem a = 0 and b = 3. Substituting these values in Eq. (9.31)
x=\frac{1}{2}[t(b-a)+a+b] \quad \text { and } \quad d x=\frac{1}{2}(b-a) d t (9.31)
gives: x=\frac{1}{2}[t(b-a)+a+b]=\frac{1}{2}[t(3-0)+0+3]=\frac{3}{2}(t+1) \quad and \quad d x=\frac{1}{2}(b-a) d t=\frac{1}{2}(3-0) d t=\frac{3}{2} d t Substituting these values in the integral gives:
I=\int_{0}^{3} e^{-x^{2}} d x=\int_{-1}^{1} f(t) d t=\int_{-1}^{1} \frac{3}{2} e^{-\left[\frac{3}{2}(t+1)\right]^{2}} d t
Step 2: Use four-point Gauss quadrature to evaluate the integral. From Eq. (9.30),
\int_{-1}^1 f(x) d x \approx C_1 f\left(x_1\right)+C_2 f\left(x_2\right)+C_3 f\left(x_3\right)+\ldots+C_n f\left(x_n\right) (9.30)
and using Table 9-1:
Table 9-1: Weight coefficients and Gauss points coordinates
Evaluating f(t)=\frac{3}{2} e^{-\left[\frac{3}{2}(t+1)\right]^{2}} gives:
\begin{aligned}& I=0.3478548 \frac{3}{2} e^{-\left[\frac{3}{2}((-0.86113631)+1)\right]^{2}}+0.6521452 \frac{3}{2} e^{-\left[\frac{3}{2}((-0.33998104)+1)\right]^{2}} \\& +0.6521452 \frac{3}{2} e^{-\left[\frac{3}{2}(0.33998104+1)\right]^{2}}+0.3478548 \frac{3}{2} e^{-\left[\frac{3}{2}(0.86113631+1)\right]^{2}}=0.8841359\end{aligned}
The exact value of the integral (when carried out analytically) is 0.8862073 . The error is only about 1%.