Let $f(x) = e^{2x}\cos3x$. Estimate the value of $f(0.5)$ using Lagrange's interpolating polynomial of degree $3$ over the nodes $x=0, x=0.3, x=0.6$ and $x=1$. Also compute the error bound over the interval $[0,1]$ and the actual error $E(0.5)$.
I am not sure whether we should use $x$ in radians or degrees.
We are given $$f(x) = e^{2x}\cos3x, x_0 = 0.0, x_1 = 0.3, x_2 = 0.6, x_3 = 1.0$$
We are asked to construct the interpolation polynomial of degree three, to approximate $f(0.5)$, to compute the error bound over the interval $[0,1]$ and the actual error $E(0.5)$.
The cubic polynomial passing through these points can be expressed as:
$$P_3(x) = y_0 L_0(x) + y_1 L_1(x) + y_2 L_2(x) + y_3 L_3(x)$$
where:
The Lagrange Interpolating Polynomial is
$$P_3(x) = -3.22551 x^3-8.31722 x^2+3.22762 x+1.$$
The formula for the error bound is given by
$$E_n(x) = {f^{n+1}(\xi(x)) \over (n+1)!} \times (x-x_0)(x-x_1)...(x-x_n)$$
Since we do not know where $\xi(x)$ is, we will find each error over the range and multiply those together, so we have
$$\max_{(x \in 0, 1)} |f^{(4)}(x)| = \max_{(x \in 0,1)} |120 e^{2 x} \sin 3 x-119 e^{2 x} \cos 3 x| = 998.291$$
Next, we need to find
$$\max_{(x \in 0, 1)} |(x-0)(x-0.3)(x-0.6)(x-1.0)| = 0.0175456$$
Thus we have an error bound of
$$E_3(x) = \dfrac{998.291}{24} \times 0.0175456 \le 0.729816$$
If we compute the actual error, we have
$$\mbox{Actual Error}~ = |f(0.5) - P_3(0.5)| = 0.0609676$$
We can also plot the actual function versus the Lagrange Interpolating Polynomial over the range