# Linear interpolation with two points

Question: $p(x)$ is the linear function that interpolates $\sin(x)$ at $0$ and $\frac{\pi}{2}$. And I need to show that $\ |p(x) - \sin(x)|\le\ \frac{1}{2}(\frac{\pi}{4})^2$

My attempt: $\ |f(x)-p(x)| \le (K_n/(n+1)!) * |W(x)|$

where $\ K_2 = -\sin(x)$ and $\max|W(x)| = ||W(x)||\inf$ where x is in $\ [0, \pi/2]$

I ended up with $\ \frac {1}{2}(x^2 - (\frac{ \pi}{2})x)$ which I cannot find a connection with the given relationship in the problem. Am I missing something?

Sorry in advanced for the poor syntax.

• First write down the expression of $p(x)$, which I don't see. – Yves Daoust Dec 15 '15 at 9:36
• @YvesDaoust p(x) was not given in the problem. – wrenyoong Dec 15 '15 at 9:37
• No but you have to find it. This is elementary from its definition. – Yves Daoust Dec 15 '15 at 9:38
• @YvesDaoust is $\ p(x) = (x-0)(x-\pi/2)$ ? – wrenyoong Dec 15 '15 at 9:42
• I don't think this is linear... – Yves Daoust Dec 15 '15 at 9:42

$p(x)=ax+b$ such that $p(0)=0$ and $p(\frac{\pi}2)=1$ That is $p(x) = \frac2{\pi} x$

The error of linear interpolation is given by $$|E(x)|=|p(x)-\sin x|=\max_{x\in[0,\pi/2]}\left|\frac{ (x-0)(x-\pi/2)}2 \left\{\frac{d^2}{dx^2}\sin\right\} (c)\right| =\max_{x\in[0,\pi/2]}\left|\frac{ (x-0)(x-\pi/2)}2 \sin(c)\right|\le \max_{x\in[0,\pi/2]}\frac{ (x-0)(x-\pi/2)}2 = \frac{1}{2} \left(\frac{\pi }{4}\right)^2$$

To show the last equality note that $\frac{d}{dx}x(x-\frac\pi2)=(x-\frac\pi2)+x=0$ iff $x=\frac\pi4$, this is of course a maximum (why)? Finally evaluate the polynomial at this point, to get the required result.

• Thank you for additional explanation on the last equality! Now I know what I misunderstood. :D – wrenyoong Dec 15 '15 at 10:18

Hint:

As $p(x)$ is linear through $(0,0)$ and $(\frac\pi2,1)$, we have $p(x)=\frac{2x}\pi$.

Then consider $|p(x)-\sin(x)|^2=(\frac{2x}\pi-\sin(x))^2$.

We find the maximum of this function by derivation

$$2(\frac2\pi-\cos(x))(\frac{2x}\pi-\sin(x)).$$

The first factor cancels for $\cos(x)=\frac2\pi$. It corresponds to a single extremum of the second factor. The latter is known to cancel for $x=0$ and $x=\frac\pi2$ and has no other root.

Hence the maximum occurs at $x=\arccos(\frac2\pi)$, with value (of the square)

$$\left(\frac2\pi\arccos(\frac2\pi)-\sqrt{1-\frac4{\pi^2}}\right)^2.$$

• Thank you so much! I knew my first step of figuring out p(x) was wrong since it can't be square function.. – wrenyoong Dec 15 '15 at 10:02
• You need to put absolute value signs around that result. The linear interpolation stays below the sine as the latter is concave. – Justpassingby Dec 15 '15 at 10:07
• @Justpassingby: I was about to do it when the telephone rang :-) – Yves Daoust Dec 15 '15 at 10:12

The maximum of the difference $\sin(x)-p(x)$ is reached when $\cos(x)=\frac2\pi,$ so the maximum difference is actually

$$\sqrt{1-\frac4{\pi^2}}-\frac2{\pi}\arccos\frac2{\pi}.$$