Compute function values using Lagrange polynomials for ODEs

32 Views Asked by At

Given the Lagrange Basis Functions:

enter image description here

And an ODE of the form:

enter image description here

enter image description here

The lagrange interpolation states that:

enter image description here

Moreover:

enter image description here

I read that the last expression allows to build a algebraic equation system of N equations by N variables and that in turn should allow computing the function evaluated at those $x(t_j)$ and then use those to determine the interpolation function.

Whenever I try to do this approach I always end up with a system whose solutions do not match with the analytical answer.

Consider this example:

$$\dot{x} = -x + t$$ $$x(0) = 5$$ $$t_0 = 0, t_1 = 1, t_2 = 2$$

The analytical solution is:

$$x(t) = t - 1 + 6\cdot e^{-t}$$

Which yield: $$x(t_0) = 5, x(t_1) \approx 2.20, x(t_2) \approx 4.04$$

Whereas when using the formula above I get: $$\hat{x}(t_0) = 5, \hat{x}(t_1) \approx 2.769, \hat{x}(t_2) \approx 3.076$$

The error is too big to be some machine error or truncation error.

Am I missing something? Is there any bibliography with a step by step example to check if I am using the correct procedure (I couldn't find anything googling)?