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.
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}$.
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.
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.
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$.