Math 104A Homework #4 ∗
General Instructions: Please write your homework papers neatly. You need to turn in both your code and descriptions on Canvas with the appropriate form that the TA requires. Write your own code individually. Do not copy codes!
1. Write a code to compute a natural spline S(x) which interpolates a collection of given points (x0, y0), (x1, y1), ..., (xn, yn) where x0 < x1 < x2 < ... < xn (do not assume they are equidis- tributed).
2. One important application of spline interpolation is the construction of smooth curves that are not necessarily the graph of a function but that have a parametric representation x = x(t) and y = y(t) for t ∈ [a,b]. Hence one needs to determine two splines interpolating (tj,xj) and (tj,yj) (j = 0,1,...n).
The arc length of the curve is a natural choice for the parameter t. However, this is not known a priori and instead the tj’s are usually chosen as the distances of consecutive points:
t0 = 0, tj = tj−1 + q(xj − xj−1)2 + (yj − yj−1)2, j = 1, 2, ...n.
Use the values in Table 1 to construct a smooth parametric representation of a curve passing through the points (xj , yj ), j = 0, 1, ..., 8 by finding the two natural cubic splines interpolating (tj , xj ) and (tj , yj ), j = 0, 1, ...8, respectively. Tabulate the coefficients of the splines and plot the resulting (parametric) curve.
∗All course materials (class lectures and discussions, handouts, homework assignments, examinations, web ma- terials) and the intellectual content of the course itself are protected by United States Federal Copyright Law, the California Civil Code. The UC Policy 102.23 expressly prohibits students (and all other persons) from recording lectures or discussions and from distributing or selling lectures notes and all other course materials without the prior written permission of Prof. Hector D. Ceniceros.
1
Table 1
j tj xj yj
0 0 1.50 0.75
1 0.618 0.90 0.90
2 0.935 0.60 1.00
3 1.255 0.35 0.80
4 1.636 0.20 0.45
5 1.905 0.10 0.20
6 2.317 0.50 0.10
7 2.827 1.00 0.20
8 3.330 1.50 0.25