- Splines: write a Matlab function
**myspline(x,f,n,k)**to plot a cubic spline passing through**n+1**data points**(x**, plotted at_{i},f_{i}), i=1,...n+1**k**additional points in**each**interval**(x**. Follow the algorithm described in Section 11.2 of the text, where the notation is actually for data points_{i}, x_{i+1})**(x**: unfortunately Matlab doesn't allow zero-subscripting. Use the free boundary (natural spline) conditions. Although the derivation is complicated, the algorithm is not:_{i},f_{i}), i=0,...n- solve the tridiagonal system at the bottom of p.243 for the
**c**. The notation_{i}**f[x**used on the top of p.244 (and also in equation (11.3b)) is from Section 10.3; it refers to the_{i}, x_{i+1}]**divided difference (f(x**, that is_{i}) - f(x_{i+1}))/(x_{i}- x_{i+1})**(f**, since there is no explicit function_{i}- f_{i+1})/(x_{i}- x_{i+1})**f**provided here, just data values**f**_{i} - plug the
**c**into equation (11.4a) and (11.4b) to get the_{i}**d**and_{i}**b**_{i} - for each
**i**, plot the polynomial**s**(see equations (11.2a) and (11.3a)) on_{i}(x)**k**equally spaced points in each interval**(x**, using_{i}, x_{i+1}**'r.'**,**'g.'**,**'b.'**, etc., for the 3rd argument to**plot**so that it doesn't do any additional interpolation and so that adjacent cubics are plotted in different colors - also plot the original data points using
**'*'**for the 3rd argument to**plot** - solve the tridiagonal system with the backslash
**\**at first to make sure it is solved correctly, and compare your spline with the one obtained and plotted with the built-in**spline**. The results will be slightly different since the latter uses different boundary conditions. - write your own tridiagonal solver
**tridiag.m**, which solves a general tridiagonal system**without pivoting and using only O(n) storage**: the input should be the 3 diagonals of the matrix stored as vectors. Call this from**myspline.m**and make sure you get the same the results as you do using the backslash**\**. How many multiplications and additions are required? Answer this in the comments.

- solve the tridiagonal system at the bottom of p.243 for the
- Parametric Piecewise Cubic Hermite Polynomials (Bezier Polynomials):
show that the formula for
**X(&tau)**and**Y(&tau)**given 2/3 of the way down the page on p.253 indeed satisfies the conditions 1/3 of the way down the page, with the derivatives scaled by 3 as explained in the middle of the page. To do this you need to- evaluate
**X(0),X(1),Y(0),Y(1)** - write down formulas for the derivatives
**X'(&tau)**and**Y'(&tau)** - evaluate
**X'(0),X'(1),Y'(0),Y'(1)**

- evaluate
- Exercise 8, p. 256 of the text, following the pattern shown in
Example 11.7, p. 253-254. Use only Bezier polynomials. You should use
**ginput**and**plot**but you may not use any built-in interpolation routines such as**spline**, etc. Email**myspline.m**and**tridiag.m**to the grader, zz299@nyu.edu, with a cc to me. He will test them on his own input. Questions 2 and 3 can be turned in either on paper or by submitting a single pdf file by email. Don't forget to include the plot that shows the guidepoints as well as the interpolation points, as well as your source code.

Reading: Chapter 11, except Section 11.3