Approximate the given integral using Gaussian quadrature

1.1k Views Asked by At

Consider the Gaussian quadrature formula for $n=2$ with weight function $w(x)=1-x^2$ and orthogonal polynomials on $(-1,1)$ given by $$P_0(x)=1, P_1(x)=x, P_2(x)=\frac{1}{4}(5x^2-1).$$

The formula is given by $$\int_{-1}^1 (1-x^2)f(x) \, dx \approx \sum_{n=1}^2 w_if(x_i).$$

For the given orthogonal polynomials the relevant weights and sampling points are given by $w_1=2/3, x_1=1/\sqrt{5}, w_2=2/3$ and $x_2=-1/\sqrt{5}$.

I want to use this formula to approximate $$\int_0^1 \sin(\pi x) \, dx.$$

However, I'm not sure how to rewrite the integral in such a way that I can use the approximation.

1

There are 1 best solutions below

2
On BEST ANSWER

By letting $x=\frac{z+1}{2}$ we have $$ \int_{0}^{1}\sin(\pi x)\,dz = \frac{1}{2}\int_{-1}^{1}\sin\left(\frac{\pi}{2}(z+1)\right)\,dz=\frac{1}{2}\int_{-1}^{1}(1-z^2)\frac{\sin(\pi(z+1)/2)}{1-z^2}\,dz $$ hence by Gaussian quadrature the LHS is approximately $$ \frac{1}{3}\cdot\left.\frac{\sin(\pi(z+1)/2)}{1-z^2}\right|_{z=-1/\sqrt{5}}+\frac{1}{3}\cdot\left.\frac{\sin(\pi(z+1)/2)}{1-z^2}\right|_{z=1/\sqrt{5}}=\frac{5}{6}\cos\frac{\pi}{2\sqrt{5}}$$ and indeed $\frac{2}{\pi}$ is pretty close to the RHS of the last line.