Celeritas 0.6.0-dev.115+3b60a5fd
|
Interpolate using a cubic spline. More...
#include <SplineInterpolator.hh>
Classes | |
struct | Spline |
(x, y) point and second derivative More... | |
Public Types | |
Type aliases | |
using | real_type = T |
Public Member Functions | |
CELER_FUNCTION | SplineInterpolator (Spline left, Spline right) |
Construct with left and right values for x, y, and the second derivative. | |
CELER_FUNCTION real_type | operator() (real_type x) const |
Interpolate using a cubic spline. | |
Interpolate using a cubic spline.
Given a set of \( n \) data points \( (x_i, y_i) \) such that \( x_0 < x_1 < \dots < x_{n - 1} \), a cubic spline \( S(x) \) interpolating on the points is a piecewise polynomial function consisting of \( n - 1 \) cubic polynomials \( S_i \) defined on \( [x_i, x_{i + 1}] \). The \( S_i \) are joined at \( x_i \) such that both the first and second derivatives, \( S'_i \) and \( S''_i \), are continuous.
The \( i^{\text{th}} \) piecewise polynomial \( S_i \) is given by:
\[ S_i(x) = a_0 + a_1(x - x_i) + a_2(x - x_i)^2 + a_3(x - x_i)^3, \]
where \( a_i \) are the polynomial coefficients, expressed in terms of the second derivatives as:
\begin{align} a_0 &= y_i \\ a_1 &= \frac{\Delta y_i}{\Delta x_i} - \frac{\Delta x_i}{6} \left[ S''_{i + 1} + 2 S''_{i} \right] \\ a_2 &= \frac{S''_i}{2} \\ a_3 &= \frac{1}{6 \Delta x_i} \left[ S''_{i + 1} - S''_i \right] \end{align}