I am having difficulties with interpolating polynomials to approximate. I am familiar when the problem involves 2 points but this particular problem involves 3 points. Can you explain the process to me? For the given function $f(x)=\sin(\pi x)$ let $x_0=1,x_1=1.25,x_2=1.6$. Construct interpolation polynomials of degree at most 1 and at most 2 to approximate $f(1.4)$ and find the absolute error.

  • 1
    $\begingroup$ Presumably, for the interpolation of degree one, you only need $x_1$ and $x_2$. $\endgroup$ – Raskolnikov Sep 12 '12 at 21:27
  • $\begingroup$ So I would interpolate 2 polynomials in this case, one for x_1 and x_2 and the other for x_0 and x_1 ? $\endgroup$ – math101 Sep 12 '12 at 21:29
  • $\begingroup$ So you chose those 2 points since we need to approximate f(1.4)? $\endgroup$ – math101 Sep 12 '12 at 21:32
  • $\begingroup$ To your last question: yes, indeed! $\endgroup$ – Raskolnikov Sep 12 '12 at 21:39
  • $\begingroup$ Yup that was correct, I got the right answer. Thanks :)))) $\endgroup$ – math101 Sep 12 '12 at 21:55

Interpolation of degree at most $1$ is linear interpolation. You only need the value of $f$ evaluated in $x_1$ and $x_2$ since $x_1<1.4<x_2$. If $P$ denotes the polynomial then $$ P(1.4) = \frac{f(x_2)-f(x_1)}{x_2-x_1}(1.4-x_1) + f(x_1) $$ Which yields $$ \varepsilon = |P(1.4)-f(1.4)| = 0.139399849 $$ Then for interpolation of degree at most $2$ you search $P(x) = a x^2 + b x +c $ such that $P(x_i)=f(x_i)$ for $i=0,1,2$. This gives you a system of three linear equations to solve. More generally this polynomial is known as Lagrange polynomial. Solving the system yields $$ P(x) = 3.5523798019047517 x^2 + -10.821281678285672 x + 7.2689018763809194 $$ and thus $$ \varepsilon = |P(1.4) - f(1.4) | = 0.0328284548$$ So second order interpolation is slightly better than naive linear interpolation ;).

You can also interpolate using a piecewise polynomial as well but in this case you get fixed degree of smoothness. For example cubic splines, which are piecewise cubic polynomials define a twice differentiable function, and not more ! The nice thing about these interpolation polynomials is that between two knots they have degree at most 3, preventing Runge's phenomenon that Lagrange interpolation polynomial present when increasing the number of knots.

  • $\begingroup$ Thanks your answer is very clear. I was getting confused there. I was just noticing your equation for the linear interpolation. I was taught a more confusing formula and find yours to be neat and clean. Thanks $\endgroup$ – math101 Sep 12 '12 at 22:03
  • $\begingroup$ First construct three polynomials $l_i(x)$, $i=1,2,3$ such that $l_i(x_j)=0$ if $i\ne j$ and $l_i(x_i)=1$. Then set $$ P(x) = l_0(x) f(x_0) + l_1(x) f(x_1) + l_2(x) f(x_2) $$ Now to construct the $l_i$'s just do as such (example with $i=0$) : $$ l_0(x) = \frac{(x-x_1)(x-x_2)}{(x_0-x_1)(x_0-x_2)} $$ $\endgroup$ – vanna Sep 12 '12 at 22:57
  • $\begingroup$ What am I doing incorrectly? $L_0(x)= \frac{3} {20}(x^2-2.85x+2)\cdot\sin( \pi \cdot1) = 0, L_1(x) = \frac{-7} {20}(x^2-2.6x+1.6)\cdot\sin( \pi *1.25), L_2 = \frac{21} {100}(x^2-2.25x+1.25)\cdot\sin( \pi \cdot1.6)$ $\endgroup$ – math101 Sep 12 '12 at 23:11
  • $\begingroup$ $L_0$ is fine but it is $\frac{20}{3}$ not its inverse. I didn't check the other ones. $\endgroup$ – vanna Sep 12 '12 at 23:16
  • 1
    $\begingroup$ @math101: $$ f(1)\frac{20}{3}(x^2-2.85x+2) -f(1.25)\frac{80}{7}(x^2-2.6x+1.6) +f(1.6)\frac{100}{21}(x^2-2.25x+1.25) $$ $\endgroup$ – robjohn Sep 12 '12 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.