Gaussian quadrature using MATLAB
Determine the value of the following integral.
The Gaussian quadrature is done using the function planar(nx), where 3nx7 and one needs to use the global xoc and woc command. Planar(nx) computes the quadrature points and weights shown elsewhere (link). Then one uses the following commands.
global xoc woc
area = 0;
area = area + f*woc(i);
The results are shown in the Table. Results obtained with only 7 points are as accurate as those obtained with the trapezoid rule and 201+401= 602 points and extrapolation (link).
Table. Integrals Calculated with Quassian Quadrature
Take Home Message: Clearly the Gaussian quadrature is very accurate.