Read this lesson as text

Spline Construction Examples

Numerical Analysis · Axiom Academy

EXAMPLE Cubic Spline Construction Building a natural cubic spline step by step Construct a natural cubic spline through the following data points: Each piece S_i(x) on [x_i, x_ i+1 ] has the form: For a natural spline , we require S''(x_0) = S''(x_n) = 0. We have n = 3 data points, giving us n-1 = 2 intervals: Since all h_i = 1, this is a uniform spline (equally spaced nodes). For natural cubic splines, the second derivatives M_i = S''(x_i) satisfy: With natural boundary conditions: M_0 = 0 and M_3 = 0 Computing the right-hand side: The tridiagonal system for interior points (i = 1, 2): This is a 2x2 system since M_0 = M_3 = 0. Using elimination or direct solution: From equation 1: 4M_1 + M_2 = -18 From equation 2: M_1 + 4M_2 = 6 Multiply eq 2 by 4: 4M_1 + 16M_2 = 24 Back substitute: M_1 = 6 - 4(2.8) = -5.2 M_0 = 0, M_1 = -5.2, M_2 = 2.8, M_3 = 0 For each segment S_i(x) = a_i + b_i(x-x_i) + c_i(x-x_i)^2 + d_i(x-x_i)^3: d_0 = (M_1 - M_0)/(6h_0) = (-5.2 - 0)/6 = -0.867 b_0 = (y_1-y_0)/h_0 - h_0(2M_0+M_1)/6 = 1 + 0.867 = 1.867 d_1 = (M_2 - M_1)/(6h_1) = 8/6 = 1.333 b_1 = (y_2-y_1)/h_1 - h_1(2M_1+M_2)/6 = -0.733 d_2 = (M_3 - M_2)/(6h_2) = -0.467 b_2 = (y_3-y_2)/h_2 - h_2(2M_2+M_3)/6 = 0.067 Based on the example above, which approach is correct?

This is the written version of the interactive lesson above. See the full Numerical Analysis course.