Numerical Analysis Homework (Python code required, need it in 12 hrs)

profilepedrocp
Homework_6_F18-2.pdf

Homework1

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 equidistributed). Your code should have a triadiagonal solver for the resulting linear system of equations (you’re not allowed to use Matlab’s \ operator to solve the linear system).

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 2 [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. (1)

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 coe�cients of the splines and plot the resulting (parametric) curve.

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

Table 1: Table of data for Problem 2

1All course materials (class lectures and discussions, handouts, homework assignments, examinations, web materials) 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 the instructor.