Derivatives
The cubic interpolation method requires first derivatives \(f'(x_i)\) at each grid point \(x_i\) to compute the polynomial coefficients, but these derivatives are typically unknown. This section describes three methods to estimate them using slope values \(m_i \approx f'(x_i)\) computed from the data. Throughout, we use the notation: grid points \(\{x_i\}\) and function values \(\{f_i = f(x_i)\}\) for \(i = 0, 1, \ldots, n-1\), with grid spacing \(h_i = x_i - x_{i-1}\).
Monotone Slope Method
The monotone slope method, based on monotone cubic interpolation3, computes derivatives at grid points to ensure that the resulting interpolant is monotonic wherever the data is monotonic.
The method computes divided differences:
Initial slope estimates are obtained by averaging adjacent divided differences:
Monotonicity is enforced through constraints:
- If \(\delta_k = 0\), set \(m_k = m_{k+1} = 0\)
- Otherwise, compute \(\alpha = m_k/\delta_k\) and \(\beta = m_{k+1}/\delta_k\)
- If \(h = \sqrt{\alpha^2 + \beta^2} > 3\), rescale: \(m_k \leftarrow 3\alpha\delta_k/h\) and \(m_{k+1} \leftarrow 3\beta\delta_k/h\)
Modified Akima Slope Method
The Modified Akima method estimates slopes as weighted averages of divided differences, providing robustness for non-monotonic data.
Slopes are computed as:
where divided differences are:
At boundaries, virtual divided differences extend the data via quadratic extrapolation:
The key refinement from Akima's 1970 formula1 is the weight definition:
This modification ensures numerical stability (guarantees \(m_i = 0\) for constant data) and eliminates spurious oscillations while maintaining smoothness.
Natural Spline Method
The natural spline method enforces \(C^2\) continuity by requiring continuous second derivatives at interior points.
For each interior point \(x_i\) (where \(i = 1, 2, \ldots, n-2\)), continuity of the second derivative requires:
This yields the tridiagonal system: \(a_i m_{i-1} + b_i m_i + c_i m_{i+1} = d_i\) with:
which is solved using the Thomas algorithm.
Boundary Conditions
Four boundary condition types complete the system:
Natural Boundary Condition
The second derivative is zero at both boundaries: \(f''(x_0) = 0\) and \(f''(x_{n-1}) = 0\), giving boundary equations:
where:
Clamped Boundary Condition
The first derivative is zero at both boundaries: \(m_0 = m_{n-1} = 0\), implemented as \(b_0 = b_{n-1} = 1\) in the tridiagonal system.
Not-a-Knot Boundary Condition
The third derivative is continuous at the first and last interior knots: \(f'''(x_1^-) = f'''(x_1^+)\) and \(f'''(x_{n-2}^-) = f'''(x_{n-2}^+)\). This condition eliminates boundary kinks by extending the polynomial smoothness.
Periodic Boundary Condition
For periodic data where \(f_0 = f_{n-1}\), the slope is also periodic:
The system becomes cyclic, with interior equations:
A cyclic variant of the Thomas algorithm is employed to solve this system.
Thomas Algorithm
The tridiagonal matrix algorithm4 solves systems of the form:
where coefficients \(a_i, b_i, c_i, d_i\) are set by the boundary conditions and interior equations above.
The algorithm proceeds in two passes:
Forward elimination: Normalize rows to create an upper triangular system:
For \(i = 1, 2, \ldots, n-1\):
Back substitution: Solve the triangular system from the last row backward:
For \(i = n-2, n-3, \ldots, 0\):
This \(O(n)\) algorithm yields the slopes \(m_i = f'(x_i)\) at each grid point.
Cyclic Thomas Algorithm
For periodic boundary conditions (\(m_0 = m_{n-1}\)), a cyclic variant handles the coupling. The method eliminates the cyclic structure by using the boundary rows to reduce the system size.
Cyclic reduction: Extract scaling factors and modify interior rows:
Solution: Apply the standard Thomas algorithm to the reduced system of size \(n-2\), then recover boundary values:
-
Akima, H., 1970, "A new method of interpolation and smooth curve fitting based on local procedures", J. ACM, 17(4):589-602. ↩
-
Modified Akima implementation details based on Cleve Moler's analysis of makima piecewise cubic interpolation. ↩
-
Monotone cubic interpolation method: Wikipedia - Monotone cubic interpolation ↩
-
Thomas algorithm overview: Wikipedia - Tridiagonal matrix algorithm ↩