Example 2.  Compare the accuracy of the Gauss-Legendre quadrature rules for n = 2, 3, and 4 points
with the Trapezoidal rule, Simpson's Rule and Simpson's [Graphics:Images/GaussLegendreMod_gr_25.gif] rule for n = 2, 3, and 4 points respectively.
Illustrate the comparisons for the integral  [Graphics:Images/GaussLegendreMod_gr_26.gif] .  

Solution 2.

First, enter the formula  [Graphics:../Images/GaussLegendreMod_gr_27.gif] .  

[Graphics:../Images/GaussLegendreMod_gr_28.gif]

[Graphics:../Images/GaussLegendreMod_gr_29.gif]

  Use Mathematica to find the true value of the integral and the "true" numerical value too.

[Graphics:../Images/GaussLegendreMod_gr_30.gif]
[Graphics:../Images/GaussLegendreMod_gr_31.gif] [Graphics:../Images/GaussLegendreMod_gr_32.gif] [Graphics:../Images/GaussLegendreMod_gr_33.gif]

Use the quadrature values obtained in Exercise 1.

Q2 = 1.69296344978122892  
Q3 = 1.71202024520190976  
Q4 = 1.71122450459948849  

Compare Gauss-Legendre quadrature 2 point rule with the Trapezoidal rule.

[Graphics:../Images/GaussLegendreMod_gr_34.gif]
[Graphics:../Images/GaussLegendreMod_gr_35.gif]
[Graphics:../Images/GaussLegendreMod_gr_36.gif]
[Graphics:../Images/GaussLegendreMod_gr_37.gif] [Graphics:../Images/GaussLegendreMod_gr_38.gif]

Compare Gauss-Legendre quadrature 3 point rule with Simpson's rule.

[Graphics:../Images/GaussLegendreMod_gr_39.gif]
[Graphics:../Images/GaussLegendreMod_gr_40.gif]
[Graphics:../Images/GaussLegendreMod_gr_41.gif] [Graphics:../Images/GaussLegendreMod_gr_42.gif] [Graphics:../Images/GaussLegendreMod_gr_43.gif]

Compare Gauss-Legendre quadrature 4 point rule with Simpson's [Graphics:../Images/GaussLegendreMod_gr_44.gif] rule.

[Graphics:../Images/GaussLegendreMod_gr_45.gif]
[Graphics:../Images/GaussLegendreMod_gr_46.gif]
[Graphics:../Images/GaussLegendreMod_gr_47.gif]
[Graphics:../Images/GaussLegendreMod_gr_48.gif] [Graphics:../Images/GaussLegendreMod_gr_49.gif]

Observe that the errors for the Trapezoidal rule, Simpson's Rule and Simpson's [Graphics:../Images/GaussLegendreMod_gr_50.gif] rule form a decreasing sequence.

[Graphics:../Images/GaussLegendreMod_gr_51.gif]

[Graphics:../Images/GaussLegendreMod_gr_52.gif]

Observe that the errors for the Gauss-Legendre quadrature rules for n = 2, 3, and 4 points form a decreasing sequence.

[Graphics:../Images/GaussLegendreMod_gr_53.gif]

[Graphics:../Images/GaussLegendreMod_gr_54.gif]

The ratios will determine how much smaller the error for Gauss Legendre quadrature is.

[Graphics:../Images/GaussLegendreMod_gr_55.gif]

[Graphics:../Images/GaussLegendreMod_gr_56.gif]

It is interesting to determine when the composite Simpson's rule is competitive with the three point Gauss Legendre rule,
and compare the number of function evaluations. For our function above the following calculations are illustrative.

[Graphics:../Images/GaussLegendreMod_gr_57.gif]
[Graphics:../Images/GaussLegendreMod_gr_58.gif]
[Graphics:../Images/GaussLegendreMod_gr_59.gif]
[Graphics:../Images/GaussLegendreMod_gr_60.gif] [Graphics:../Images/GaussLegendreMod_gr_61.gif]

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2003