# Gaussian Quadrature -Deriving a Formula-

eThe following is an exercise in the problem section of the Gaussian Quadrature chapter.

The theorem:

Derive a formula of the form $$\int_{a}^{b} f(x)dx \approx w_0f(x_0) + w_1f(x_1) + w_2f'(x_2) + w_3f'(x_3)$$

I don't really know how to even start this. I have the Gaussian Quadrature theorem, but...I suppose I don't know how to use it. Can anyone show me how to do this?

We have four weights, $w_0, w_1,w_2,w_3$ and four nodes $x_0, x_1,x_2,x_3$. So our polynomial $q(x)$ will be of degree $4$. (Will the number of weights always determine the degree of the polynomial?). So from $$\int_{a}^{b} x^kq(x)dx = 0$$ where $0 \leq k \leq n$ and the degree of $q(x)$ is $n+1$, we can write $$\int q(x)dx = \int xq(x) = \int x^2q(x) = 0$$ right?

From here I don't know what to do.

Let's look first at $\int_{-1}^{1} f(t) \ dt$.

We want the formula to evaluate $\int_{-1}^{1} dt, \int_{-1}^{1} t \ dt, \int_{-1}^{1} t^{2} \ dt, \int_{-1}^{1} t^{3} \ dt, \int_{-1}^{1} t^{4} \ dt, \int_{-1}^{1} t^{5} \ dt, \int_{-1}^{1} t^{6} \ dt$ and $\int_{-1}^{1} t^{7} \ dt$ exactly.

That leads to the following system of equations:

$$2 = \omega_{0} + \omega_{1}$$

$$0 = \omega_{0} x_{0} + \omega_{1} x_{1}+ \omega_{2}+\omega_{3}$$

$$\frac{2}{3} = \omega_{0} x_{0}^{2} + \omega_{1} x_{1}^{2} + 2 \omega_{2} x_{2} + 2 \omega_{3} x_{3}$$

$$0 = \omega_{0} x_{0}^{3} + \omega_{1} x_{1}^{3}+ 3 \omega_{2} x_{2}^{2} + 3 \omega_{3} x_{3}^{2}$$

$$\frac{2}{5} = \omega_{0} x_{0}^{4} + \omega_{1} x_{1}^{4}+ 4 \omega_{2} x_{2}^{3} + 4 \omega_{3} x_{3}^{3}$$

$$0 = \omega_{0} x_{0}^{5} + \omega_{1} x_{1}^{5} + 5 \omega_{2} x_{2}^{4} + 5 \omega_{3} x_{3}^{4}$$

$$\frac{2}{7} = \omega_{0} x_{0}^{6} + \omega_{1} x_{1}^{6} + 6 \omega_{2} x_{2}^{5} + 6\omega_{3} x_{3}^{5}$$

$$0 = \omega_{0} x_{0}^{7} + \omega_{1} x_{1}^{7} + 7 \omega_{2} x_{2}^{6} + 7\omega_{3} x_{3}^{6}$$

Solve the system using a numerical solver.

Then use the the fact that $$\int_{a}^{b} f(x) \ dx = \frac{b-a}{2} \int_{-1}^{1} f \Big(a+(1+t)\frac{b-a}{2} \Big) \ dt$$