Exercise of quadrature and error.

numerical methodspythonquadrature

I am trying to solve the following problem, but I can not understand it(in the school they did not teach us quadrature).

From the nodes $x_0 = \frac{2}{3}$, $x_1 = \frac{5}{9}$ and $x_2 = \frac{65}{81}$ for the quadrature formula:

$$\int_0^1{xf(x)\delta(x)} \approx A_0f(x_0)+ A_1f(x_1)+ A_2f(x_2)$$

Answer the following questions:

  • Explain how you get the coefficients $A_i$ $\forall i \in [1,2,3]$. You must use the Sympy library (Symbolic Python) to get your answer.

  • What is the maximum degree of a polynomial f for which this formula is exact?.

  • Is it a Gaussian square ?. Argue your answer.
  • Use your formula to approximate:
    $$ \int^1_0 xe^xd x $$
    What is the error?

I have no idea how to respond to the request, if you could help me I would appreciate it. Thank you.

Best Answer

  1. You get the coefficients just be demanding that the rule is exact (gives you the exact result) for polynomials up to a certain degree. Since the rule is linear in $f$, you just need to check for the polynomials $1, x, x^2, \cdots$ Since you have three coefficients to determine, you can use the system $$ \begin{cases} A_0+A_1+A_2 = \int_0^1 x \, dx\\ x_0 A_0 + x_1 A_1 + x_2 A_2=\int_0^1 x^2dx \\x_0^2 A_0 + x_1^2 A_1 + x_2^2 A_2 = \int_0^1 x^3 dx \end{cases} $$

This amounts to requiring the the rule is exact for polynomials of degree $\leq 2$. You will get $A_0=-\frac{59}{44}, A_1=\frac{81}{80}, A_2=\frac{719}{880}$.

  1. From (1) we know that the degree is a least 2. To compute the actual degree, we just test the rule for polynomials of increasing order. Using the rule for $f(x)=x^3$ does not give the correct value for the integral, so the rule has degree 2.

  2. It is not a Gaussian rule because it does not have the correct degree. If it was a Gaussian rule it would have degree 5.

  3. Using the formula with $f(x)=e^x$ you get $$ \int_0^1 x e^x dx \approx \frac{81 e^{5/9}}{80}-\frac{59 e^{2/3}}{44}+\frac{729 e^{65/81}}{880}=1.00118 $$

The correct value can be computed using integration by parts... $\int_0^1 x e^x dx = 1$, so the absolute error is $0.00118$.

Related Question