# Thread: Numerical analysis, calculating an integral exactly for some polynomials

1. ## Numerical analysis, calculating an integral exactly for some polynomials

The problem reads "I must calculate $\int _{-1}^1 f(x)x^2 dx$ via a quadrature rule of the form $\int _{-1}^1 f(x)x^2 dx ~A_0 f (x_0)+A_1 f(x_1)$ that is exact for polynomials with degree lesser or equal to 3."
Attempt: Not much. I don't understand why use the "f(x)" in the expression. Does this mean that f(x) is a polynomial of degree lesser or equal to 1?

The expression must be exact for polynomials up to degree 3. It's equivalent to say it must be exact for $f(x)x^2= 1$, $x$, $x^2$ and $x^3$. This makes $f(x)=\frac{1}{x^2}$, $\frac{1}{x}$, $1$ and $x$.
Evaluating the expression, I get the following system of equations:
$\frac{A_0}{x_0 ^2}+\frac{A_1}{x_1 ^2}=2$
$\frac{A_0}{x_0}+\frac{A_1}{x_1}=0$
$A_0+A_1=\frac{2}{3}$
$x_0A_0+x_1A_1=0.$
If I understood well, I must solve for $x_0$, $x_1$, $A_0$ and $A_1$?
The system is not even linear... Hmm. I probably went wrong somewhere. I would appreciate a tip on this one, thanks in advance.

2. The Gauss Legendre quadrature method...

Legendre-Gauss Quadrature -- from Wolfram MathWorld

... compute a definite integral as...

$\int_{-1}^{1} f(x)\ dx \sim \sum_{i=1}^{n} a_{i}\ f(x_{i})$ (1)

... and the result is exact if f(x) is a polynomial of degree $r \le 2n-1$. For n=2 $x_{i} = \pm \sqrt{\frac{1}{3}}$ and $a_{i}=1$...

Kind regards

$\chi$ $\sigma$

3. Thanks chisigma, I appreciate your help. I looked into mathworld but didn't understand how you found that the formula is exact for a polynomial of degree lesser or equal than 2n-1. Nor do I know how you found out x_i and a_i.
I've searched into wikipedia about Gaussian quadrature and they indeed find the same values. It seems I must dig into Legrendre's polynomials in order to understand what's going on.
Also, I don't know what's wrong with my method. Could you tell me what did I do wrong?!

4. Originally Posted by arbolis
Thanks chisigma, I appreciate your help. I looked into mathworld but didn't understand how you found that the formula is exact for a polynomial of degree lesser or equal than 2n-1.
The error formula gives that the error is some multiple, depending only on n, times the value of the derivative of order 2n at some point in the interval. But the derivative of order 2n is identicaly zero for a polynomial of degree 2n-1 or less.

CB

5. Originally Posted by arbolis
The problem reads "I must calculate $\int _{-1}^1 f(x)x^2 dx$ via a quadrature rule of the form $\int _{-1}^1 f(x)x^2 dx ~A_0 f (x_0)+A_1 f(x_1)$ that is exact for polynomials with degree lesser or equal to 3."
Attempt: Not much. I don't understand why use the "f(x)" in the expression. Does this mean that f(x) is a polynomial of degree lesser or equal to 1?

The expression must be exact for polynomials up to degree 3. It's equivalent to say it must be exact for $f(x)x^2= 1$, $x$, $x^2$ and $x^3$. .
Exact for $f(x)=1, x, x^2, x^3$ or $f(x)x^2=x^2,x^3,x^4,x^5$

CB

6. ## Re: Numerical analysis, calculating an integral exactly for some polynomials

Originally Posted by CaptainBlack
Exact for $f(x)=1, x, x^2, x^3$ or $f(x)x^2=x^2,x^3,x^4,x^5$

CB
I have to say this even if late: Thank you very much.