Demonstration of Gaussian Quadrature

To be noted in this program is that we can transfer the name of a given function to integrate. In the table here we show the results for the first integral using various mesh points,.

\( N \) Trapez Simpson Gauss-Legendre
10 1.821020 1.214025 0.1460448
20 0.912678 0.609897 0.2178091
40 0.478456 0.333714 0.2193834
100 0.273724 0.231290 0.2193839
1000 0.219984 0.219387 0.2193839

We note here that, since the area over where we integrate is rather large and the integrand goes slowly to zero for large values of \( x \), both the trapezoidal rule and Simpson's method need quite many points in order to approach the Gauss-Legendre method. This integrand demonstrates clearly the strength of the Gauss-Legendre method (and other GQ methods as well), viz., few points are needed in order to achieve a very high precision.