Next: Exercise 16. Up: Exercises Previous: Exercise 14.

Exercise 15.

Given a sequence of points where the 's are distinct, the Maple library function interp computes a polynomial of degree which interpolates the points using the Newton interpolation algorithm. Write a Maple procedure which computes a natural cubic spline for the points. A natural cubic spline is a piecewise cubic polynomial where each interval is defined by the cubic polynomial

where the unknown coefficients are uniquely determined by the following conditions

These conditions mean that the resulting piecewise polynomial is continuous. Write a Maple procedure which on input of the points as a list of 's in the form [x0, y0, x1, y1, ..., xn, yn], and a variable, outputs a list of the segment polynomials [f1, f2, ..., fn]. This requires that you create the segment polynomials with unknown coefficients, use Maple to compute the derivatives and solve the resulting equations. For example


> spline([0,1,2,3],[0,1,1,2],x);

          3               3      2                      3      2
  [- 1/3 x  + 4/3 x, 2/3 x  - 3 x  + 13/3 x - 1, - 1/3 x  + 3 x  - 23/3 x + 7]


bondaren@thsun1.jinr.ru