Integration error numerical method

161 Views Asked by At

Is there someone who can help me with this?

enter image description here

I have found that the error is given by

$$ f(t) - p_n(t) = \frac{1}{(n+1)!} f^{(n+1)}(\xi_t) \prod_{k=0}^n \left(t - t_k \right) $$ where the derivative is defined by

enter image description here

Can someone help me with some advice?

What integral did I actually have to solve?

I can't see what will happen with $ξ_t?$

2

There are 2 best solutions below

3
On

Dr. Lutz Lehmann. I don't think I really understand it. But I have found a formula in my notes that says: enter image description here . So if we take n=10 as example and look on the graph in math.stackexchange.com/a/3412386/115115 . Then we can write the integral as enter image description here If I try to solve this in Maple I get enter image description here. Is that correct? Then I just have to solve the integral with a numerical method in stead of with Maple?

0
On

What was required of you was something like the following, possibly with hand-made implementations of the interpolation and quadrature functions.

from scipy.interpolate import lagrange
from scipy.integrate import quad
from scipy import exp, sin, cos, pi, linspace, polyval

f=lambda x: exp(-x)*cos(4*pi*x)
for n in [10,50,100]:
    x = linspace(0,3,n+1);
    y = f(x)
    pn = lagrange(x,y)
    s = [ quad(lambda t: abs(f(t)-pn(t)), x[k],x[k+1], epsabs=10**((n/10)**2-6), epsrel=5e-6, limit=200) for k in range(n) ]
    print n, sum(ss[0] for ss in s), sum(ss[1] for ss in s)```

which returns the list of error integrals and estimated error of that value

 10  1.92296458696      6.07592167557e-06
 50  8.31497502325e+24  1.11595406939e+15
100  1.90234868668e+68  2.11203131282e+54

This demonstrates the rapid growth of the error with rising degree.

If you use alternatively the Chebyshev points, you get the error integrals

for n in [10,50,100]:
    x = 3*cos(linspace(-pi,0,n+1));
    y = f(x)
    pn = lagrange(x,y)
    s = [ quad(lambda t: abs(f(t)-pn(t)), x[k],x[k+1], epsabs=10**((n/10)**2-6), epsrel=5e-6, limit=200) for k in range(n) ]
    print n, sum(ss[0] for ss in s), sum(ss[1] for ss in s)```

which returns the list of error integrals and estimated error of that value

 10  19.3439343927      1.06752067248e-06
 50  40449529.2343      0.0839580123975
100  3.26753638128e+32  3.64906319354e+18

This is slightly better than the equidistant result in the larger degrees.