Simple Gaussian Quadrature Confusion

503 Views Asked by At

I'm trying to compute $\int_0^4 x^2 dx$ using 2-point Gaussian quadrature. This should give an exact result since for 2 points, we can exactly handle polynomials of degree 2*2-1=3.

By the usual technique, we must first transform this integral to the range $[-1,1]$. This is done using the formula (see change of interval section on this Wikipedia page: https://en.wikipedia.org/wiki/Gaussian_quadrature) by

$\int_0^4 f(x) dx = \frac{4-0}{2} \int_{-1}^1 f(\frac{4-0}{2}x + \frac{4+0}{2}) dx = 2 \int_{-1}^1 f(2x+2) dx$,

and for my function $f(x)=x^2$, this gives

$\int_0^4 x^2 dx = \int_{-1}^1 (2x+2)^2 dx$.

Now 2-point Gaussian quadrature tells me that $\int_{-1}^1 f(x) dx = f(\frac{1}{\sqrt{3}}) + f(-\frac{1}{\sqrt{3}})$ (these weights and points are listed in the first table on the Wikipedia page I linked to above). Now, if I actually evaluate this, I get

$\int_0^4 x^2 dx = \int_{-1}^1 (2x+2)^2 dx = (\frac{2}{\sqrt{3}} + 2)^2 + (-\frac{2}{\sqrt{3}} + 2)^2 = \frac{32}{\sqrt{3}}$.

However, the original integral gives $\int_0^4 x^2 = \frac{x^3}{3}|_0^4 = \frac{256}{3}$ and so my Gaussian quadrature approach is clearly miles off of the actual answer! Given that $x^2$ has degree $\leq 3$, a 2-point Gaussian quadrature should give the exact answer and so my question is basically what have I done wrong?!?!?

Thanks.

1

There are 1 best solutions below

2
On BEST ANSWER

First off, you forgot the factor of $2$ in the transformation, i.e.

$$\int_{0}^{4} x^2 dx = 2\int_{-1}^{1}(2x+2)^2 dx$$

Secondly your calculation is wrong, you should get

$$\left(\frac{2}{\sqrt{3}} + 2\right)^2 + \left(-\frac{2}{\sqrt{3}} + 2\right)^2 = \frac{32}{3}$$

Finally, $4^3 = 64$. If you correct all your mistakes you'll get the correct answer of $64/3$ using both methods.