I have been trying to solve a problem on Lagrange Interpolation from the book Numerical Analysis 10th Edition by Richard Burden. I have been stuck on the first question it for hours and cannot figure it out.
The question is: For the given functions $f(x)$ let $x_0 = 0, x_1= 0.6, x_2 = 0.9$ Construct interpolation polynomials of degree at most one and at most two to approximate $f(0.45)$
$(a) f(x) = \cos x$
The answer I get for two approximate is: $6.79012 x^2 - 7.40741x + 1.5$
The answer in the book is: $-0.452592x^2 - 0.0131009x +1$
I tried this in python using scipy interpolate Library's Lagrange function and the answer it gave was: $-0.4311x^2 - 0.03246x + 1$
May I ask if anyone can provide correct working of this question.
Step 1 Calculate $L_0, L_1, L_2$
$L_0 = (1/0.36)*(x-0.6)*(x-0.9), L_1 = (1/0.36)*x*(x-0.9), L_2 =(1/0.81)*x*(x-0.6)$
Step 2: $L_0+L_1+L_2$
Solving this I get = $6.79012 x^2 - 7.40741x + 1.5$