Cubic Splines for Curves y = f(x)

Consider (n+1) interpolation points \((x_i, f(x_i))\), \(i=0,1,\dots,n\), through which we want to construct a curve that is as differentiable as possible. In each interval \([x_i, x_{i+1}]\) of length \(h_i = x_{i+1}-x_i\), we use a cubic polynomial of the form:

pi(x) = fi + f'i(x-xi) + f''i/2! (x-xi)² + f'''i/3! (x-xi

Each polynomial \(p_i(x)\) is connected to its neighbors so that the resulting curve is twice differentiable. This is the principle of cubic spline interpolation. Notice that each polynomial is expressed similarly to a Taylor expansion around \(x_i\). The coefficients \(f_i, f'_i, f''_i, f'''_i\) represent the value of the spline and its first three derivatives at \(x_i\):

  • \(p_i(x_i) = f_i\)
  • \(p'_i(x_i) = f'_i\)
  • \(p''_i(x_i) = f''_i\)
  • \(p'''_i(x_i) = f'''_i\)

With \(n+1\) points, there are \(n\) intervals and \(4n\) unknown coefficients. By introducing the second derivative \(f''_n\) at \(x_n\), we have a total of \(4n+1\) unknowns. These are reduced using continuity conditions and the resulting tridiagonal system can be solved efficiently.

🔹 Key Continuity Conditions

  • Each polynomial passes through its interval endpoints: \(p_i(x_i) = f(x_i)\) and \(p_i(x_{i+1}) = f(x_{i+1})\).
  • Continuity of the second derivatives at interior nodes: \(p''_i(x_{i+1}) = p''_{i+1}(x_{i+1})\).
  • Continuity of the first derivatives at interior nodes: \(p'_i(x_{i+1}) = p'_{i+1}(x_{i+1})\).

Using these conditions, all unknowns can be expressed in terms of the second derivatives \(f''_i\). The system then reduces to \(n+1\) equations for \(n+1\) unknowns:

hi/(hi+hi+1) f''_i + 2 f''_{i+1} + hi+1/(hi+hi+1) f''_{i+2} = 6 f[x_i, x_{i+1}, x_{i+2}], for i=0,...,n-2

For uniform spacing \(h_i = h\), this simplifies to a classic tridiagonal matrix with diagonal entries 2 and off-diagonals 1/2, independent of \(h\).

🔹 Boundary Conditions

Additional equations are needed to complete the system:

  • Natural spline: \(f''_0 = f''_n = 0\)
  • Clamped spline: specify first derivatives at endpoints \(p'_0(x_0) = a\), \(p'_{n-1}(x_n) = b\)
  • “Not-a-knot” spline: eliminate the first and last interior nodes virtually, imposing continuity of third derivatives at \(x_1\) and \(x_{n-1}\)
  • Periodic spline: impose \(f(x_0) = f(x_n), f'(x_0) = f'(x_n), f''(x_0) = f''(x_n)\)

Each choice leads to a slightly different linear system, and the selection depends on the problem and available information.

Last modified: Saturday, 15 November 2025, 1:28 AM