代做104A Homework 2代写数据结构语言
- 首页 >> Database104A Homework 2
July 2024
1 Theory
1.1 Splines
Let s(x) be the natural cubic spline on [a, b] i.e. s(x) = si(x) on [xi , xi+1], i = 0, . . . ,(n − 1). Show that
for any g ∈ C2([a, b]) such that g(xi) = yi , i = 0, . . . , n. Hint: consider h(x) = s(x) − g(x) and rewrite g(x).
1.2 Lagrange
Prove that the functions form. a basis for degree n polynomials.
2 Coding
2.1 Spline
Consider data points (xi, yi) with {xi} equidistant. Let h = (xi+1 − xi) for any i = 0, . . . ,(n − 1) and s(x) the piecewise natural cubic spline. Denote zi = s ′′(xi). The tridiagonal system stems from equation (10) in Chapter 6.4,
Setup and solve the tridiagonal system for , you can use (Scipy) or (R) linear algebra libraries. The splines then can be evaluated with and equation (7) in Chapter 6.4. Evaluate them at a given set of test values. Use the function signature,
findAndEvalSpline(double[] x data, double[] y data, double[] x testVals) return double[] spline testVals.