# determine the error bound for the interpolation error at $x = \frac{\pi}{4}.$

I have been able to derive the interpolation polynomial $$P_2(x)$$ of degree two which interpolates $$f(x) = \sin x$$, given the points $$(0,0), \left(\frac{\pi}{2}, 1\right), (\pi, 0).$$

Solution: $$P_2(x) = \frac{4}{\pi ^2}x(\pi - x)$$

Here is the question below I am having trouble with

Calculate $$P_2\left(\frac{\pi}{4}\right)$$, an approximation for $$f\left( \frac{\pi}{4}\right) = \sin \left( \frac{\pi}{4} \right)$$ and determine the error bound for the interpolation error at $$x = \frac{\pi}{4}.$$

Calculating $$P_2\left(\frac{\pi}{4}\right)$$

$$P_2\left(\frac{\pi}{4}\right) = \frac{4}{\pi ^2} \times \frac{\pi}{4}\left( \pi - \frac{\pi}{4} \right)= \frac{3}{4}$$

If we plug $$x = \frac{\pi}{4}$$ into $$f(x) = \sin x$$ we get $$f(\pi /4) = \sin (\pi /4) \approx 0.7071$$

Here is my attempt below at finding the error bound

Writing the error as $$err(x) = \sin x - P_2(x) = \sin x - \frac{4}{\pi ^2}x(\pi - x)$$

Differentiating once gives,

$$\cos (x) - \frac{4(\pi - 2x)}{\pi ^2}$$

Differentiating twice gives,

$$\frac{8}{\pi ^2}-\sin(x)$$

Finally differentiating a third time gives,

$$- \cos x$$

But how do I use this to get my error bound

• – Andrei Nov 1 '18 at 14:54
• I have been trying but I dont understand how to do it. Could you make a post? – jh123 Nov 1 '18 at 14:55

For a polynomial interpolation of order $$n$$, the maximum error is given by $${\rm err}=\frac{1}{(n+1)!}\max |f^{(n+1)}(x)|\max|\prod_{p=0}^n(x-x_p)|$$ Here $$x_p$$ are the roots of your polynomial. Let's suppose that you are interested in finding the maximum only in the interval from $$0$$ to $$\pi$$. The maximum of the derivative in your case is $$1$$, the maximum for the product $$x(\pi-x)$$ occurs at $$\pi/2$$ so $${\rm err}=\frac{1}{3!}1\left(\frac\pi2\right)^2$$
• Outside of the interval the product will increase. Say at very large $x$, the product part is approximately $-x^2$. That means that the error in your interpolation is very large. You can see this by plotting the two curves, say from $0$ to $10$ – Andrei Nov 1 '18 at 15:17
• Okay and I'm only worried about my interval. Why is $\pi /2$ squared? – jh123 Nov 1 '18 at 15:19
• Plug in $x=\pi/2$ in $x(\pi-x)$ – Andrei Nov 1 '18 at 15:20
• Okay and the max is 1 because when we plug in $0,\pi /2, \pi$ into our third derivative which is $-cosx$ the max value is 1? – jh123 Nov 1 '18 at 15:24