Skip to article frontmatterSkip to article content

Polynomial interpolation

In Polynomial interpolation and The interpolation problem we encountered polynomial interpolation for the n+1n+1 data points (t0,y0),,(tn,yn)(t_0,y_0),\ldots, (t_n,y_n). As before, we use tit_i to denote interpolation or data nodes, and xx to denote the independent variable. Remember that while our mathematical notation starts indexing the points at zero, in our codes we have to shift the indices up by 1.

Theoretically, we can always construct an interpolating polynomial, and the result is unique among polynomials whose degree is less than n+1n+1.

9.1.1Lagrange formula

In our earlier encounters with polynomial interpolation, we found the interpolant by solving a linear system of equations with a Vandermonde matrix. The first step was to express the polynomial in the natural monomial basis 1,x,x2,1,x,x^2,\ldots. However, as we saw in Piecewise linear interpolation, no basis is more convenient than a cardinal basis, in which each member is one at a single node and zero at all of the other nodes.

It is surprisingly straightforward to construct a cardinal basis for global polynomial interpolation. By definition, each member k\ell_{k} of the basis, for k=0,,nk=0,\ldots,n, is an nnth degree polynomial satisfying the cardinality conditions

k(tj)={1if j=k,0otherwise. \ell_{k}(t_j) = \begin{cases} 1 &\text{if $j=k$,}\\ 0 & \text{otherwise.} \end{cases}

Recall that any polynomial of degree nn can be expressed as

c(xr1)(xr2)(xrn)=ck=1n(xrk),c(x-r_1)(x-r_2)\dots(x-r_n) = c\prod_{k=1}^n(x-r_k),

where r1,,rnr_1,\dots,r_n are the roots of the polynomial and cc is a constant. The conditions (9.1.1) give all nn roots of k\ell_{k}, and the normalization k(tk)=1\ell_{k}(t_k)=1 tells us how to find cc.

Because they are a cardinal basis, the Lagrange polynomials lead to a simple expression for the polynomial interpolating the (tk,yk)(t_k,y_k) points.

At this point we can say that we have completed the proof of Theorem 9.1.1.

9.1.2Error formula

In addition to existence, uniqueness, and the constructive Lagrange formula, we have a useful formula for the error in a polynomial interpolant when the data are samples of a smooth function. We will refer to the following definition.

Usually f(n+1)f^{(n+1)} and the function ξ(x)\xi(x) are unknown. The importance of the formula (9.1.8) is how it helps to express the error as a function of xx, and its dependence on the nodes t0,,tnt_0,\dots,t_n. We will exploit this knowledge later.

For equispaced nodes, Theorem 9.1.1 has an immediate consequence.

This result is consistent with our observations in Convergence of finite differences: piecewise linear interpolation with node spacing hh has accuracy O(h2)O(h^2), and the error of a finite-difference method for the first derivative based on n+1n+1 nodes of spacing hh is O(hn)O(h^n), remembering the division by hh in a finite-difference formula.

As presented in (9.1.4), the Lagrange formula is not a good choice for numerical computation, because it is unstable (see Exercise 7). In the next section we derive an algebraically equivalent formula that is both numerically stable and faster to apply.

9.1.3Exercises

  1. ✍ Write out the Lagrange form of the interpolating polynomial of degree nn for the given functions and nodes. Using a calculator, evaluate the polynomial at x=π/4x=\pi/4 and compute the error there.

    (a) f(x)=sin(x), n=1, t0=0,t1=π/2f(x) = \sin(x), \ n=1, \ t_0=0, t_1 = \pi/2

    (b) f(x)=sin(x), n=2, t0=0,t1=π/6,t2=π/2f(x) = \sin(x), \ n=2, \ t_0=0, t_1 = \pi/6, t_2 = \pi/2

    (c) f(x)=cos(x), n=2, t0=0,t1=π/3,t2=π/2f(x) = \cos(x), \ n=2, \ t_0=0, t_1 = \pi/3, t_2 = \pi/2

    (d) f(x)=tanh(x), n=2, t0=0,t1=π/3,t2=π/2f(x) = \tanh(x), \ n=2, \ t_0=0, t_1 = \pi/3, t_2 = \pi/2

  2. ⌨ For each case, plot the requested Lagrange cardinal polynomial for the given set of nodes over the interval [t0,tn][t_0,t_n]. Superimpose dots or circles for the points represented by the cardinal conditions (9.1.1).

    (a) n=2,t0=1,t1=0.2,t2=0,2(x)n=2,\quad t_0=-1, \, t_1=-0.2,\, t_2=0, \quad \ell_2(x)

    (b) n=4,t0=0,t1=1,t2=1.5,t3=2.5,t4=3,3(x)n=4,\quad t_0=0, \, t_1=1,\, t_2=1.5,\, t_3=2.5,\, t_4=3, \quad \ell_3(x)

    (c) n=20,ti=i/n for i=0,,n,0(x)n=20, \quad t_i=i/n \text{ for } i=0,\ldots,n, \quad \ell_0(x)

    (d) n=20,ti=i/n for i=0,,n,10(x)n=20, \quad t_i=i/n \text{ for } i=0,\ldots,n, \quad \ell_{10}(x)

    (e) n=40,ti=i/n for i=0,,n,20(x)n=40, \quad t_i=i/n \text{ for } i=0,\ldots,n, \quad \ell_{20}(x)

  3. ✍ Suppose pp is the quadratic polynomial interpolating the points (2,12)(-2,12), (1,3a)(1,3a), and (2,0)(2,0). Use (9.1.4) to compute p(0)p'(0).

  4. ✍ Explain carefully why using (9.1.4) to compute p(x)p(x) at a single value of xx takes O(n2)O(n^2) floating-point operations.

  5. ✍ Explain why for any distribution of nodes and all xx,

    1=k=0nk(x).1 = \sum_{k=0}^n \ell_k(x).

    (Hint: This problem does not require any hand computation or manipulation. What is being interpolated here?)

  6. ✍ Show that

    k(x)=Φ(x)(xtk)Φ(tk),\ell_k(x) = \frac{\Phi(x)}{(x-t_k)\Phi'(t_k)},

    where Φ is the function defined in (9.1.7).

  1. ✍ Consider the nodes t0=0t_0=0, t1=1t_1=1, t2=βt_2=\beta, where β>1\beta>1.

    (a) Write out the Lagrange cardinal polynomials 0\ell_0, 1\ell_1, and 2\ell_2.

    (b) Set x=1/2x=1/2 in the part (a) results, and suppose y1=y2y_1 = y_2. As β1\beta\to 1 from above, why should we expect subtractive cancellation?