Problems from Lagrange's method

Determine the value of $$f\Big( \dfrac{\pi}{3}\Big) $$ if $$f(x)= \sin(x)$$ knowing the following values of the function:

$$x$$ $$0$$ $$\dfrac{\pi}{6}$$ $$\dfrac{\pi}{2}$$
$$\sin(x)$$ $$0$$ $$\dfrac{1}{2}$$ $$1$$

and give a bound for the error.

See development and solution

Development:

We have $$n +1 = 3$$ points, therefore $$n = 2$$. The Lagrange polynomial is written as:

$$ \begin{array}{rl} P_2(x) =& f_0\cdot l_0(x)+f_1\cdot l_1(x)+f_2\cdot l_2(x) \\ =& 0\cdot l_0(x)+\dfrac{1}{2}\cdot l_1(x)+\dfrac{1}\cdot l_2(x)= \dfrac{1}{2}\cdot l_1(x)+l_2(x) \end{array} $$

Let's calculate $$l_1(x)$$ and $$l_2(x)$$:

$$$ \begin{array}{rl} l_1(x)=& \dfrac{(x-x_0)\cdot(x-x_2)}{(x_1-x_0)\cdot(x_1-x_2)} = \dfrac{(x-0)\cdot(x-\dfrac{\pi}{2})}{(\dfrac{\pi}{6}-0)\cdot(\dfrac{\pi}{6}-\dfrac{\pi}{2})} \\ =& \dfrac{x^2-\dfrac{\pi}{2}x}{\dfrac{\pi}{6}\cdot\big(\dfrac{-\pi}{3})}= -\dfrac{18}{\pi^2}x^2+\dfrac{9}{\pi}x \\ l_2(x) =& \dfrac{(x-x_0)\cdot(x-x_1)}{(x_2-x_0)\cdot(x_2-x_1)} = \dfrac{(x-0)\cdot(x-\dfrac{\pi}{6})}{(\dfrac{\pi}{2}-0)\cdot(\dfrac{\pi}{2}-\dfrac{\pi}{6})} \\ =& \dfrac{x^2-\dfrac{\pi}{6}x}{\dfrac{\pi}{2}\cdot\big(\dfrac{\pi}{3})}= \dfrac{6}{\pi^2}x^2-\dfrac{1}{\pi}x \end{array} $$$

Replacing the obtained values:

$$$ \begin{array}{rl} P_2(x)=&\dfrac{1}{2}\cdot l_1(x)+l_2(x)= \dfrac{1}{2}\cdot\Big( -\dfrac{18}{\pi^2}x^2+\dfrac{9}{\pi}x \Big) + \dfrac{6}{\pi^2}x^2-\dfrac{1}{\pi}x \\ =& -\dfrac{9}{\pi^2}x^2+\dfrac{9}{2\pi}x + \dfrac{6}{\pi^2}x^2-\dfrac{1}{\pi}x = -\dfrac{3}{\pi^2}x^2+\dfrac{7}{2\pi}x \end{array} $$$

Thus:

$$$\sin\Big( \dfrac{\pi}{3} \Big) = f\Big( \dfrac{\pi}{3} \Big) \approx P_2 \Big( \dfrac{\pi}{3} \Big) = \dfrac{5}{6}=0.8333\dots$$$

To give a bound for the error, it is necessary to know $$f^{(n+1)}(x)=f^{(3)}(x)$$. In our case,

$$$f^{(3)}(x)=-\cos(x) \Rightarrow |f^{(3)}(x)|=|\cos(x)|\leqslant 1$$$

Therefore: $$$\Big| f\Big( \dfrac{\pi}{3} \Big) - P_2 \Big( \dfrac{\pi}{3} \Big) \Big| \leqslant \dfrac{1}{6}\cdot \dfrac{\pi}{3}\cdot \dfrac{\pi}{6}\cdot \dfrac{\pi}{6} = \dfrac{\pi}{648}=0.047 \leqslant 0.5 \cdot 10^{-1}$$$

Solution:

$$\sin\Big( \dfrac{\pi}{3} \Big) =0.8333 \quad$$ and $$\quad |\text{error}|\leqslant 0.05$$

Hide solution and development
View theory