Skip to content
All library documents

Spline Sensitivities from the Collocation System

Article Quant Q&A · Author: imyafeng

Summary

The document addresses how to calculate the sensitivity of a cubic spline’s interpolated value to its input data values. It explains why differentiating only the local polynomial coefficients as if they depended independently on the two neighboring observations gives an incorrect result: spline coefficients are determined together through a linear collocation system, including interpolation conditions and any continuity or endpoint constraints.

Writing that system as a matrix equation, the coefficient vector is the inverse system matrix applied to the vector of data and constraints. An interpolated value is then a basis row evaluated at the target location multiplied by the coefficient vector. Differentiating this expression gives the basis row times the inverse collocation matrix, which provides sensitivities with respect to the system inputs. The response establishes the general matrix method but does not spell out boundary conditions, numerical implementation, or a worked DV01 calculation. The applicable sensitivity entries depend on which inputs are treated as variable and how the spline constraints are specified.

Key ideas

  • Spline coefficients are solved jointly through a linear system rather than independently on each interval.
  • The system inputs include data values and may also include continuity or endpoint constraints.
  • An interpolated value can be expressed as a location-dependent basis row multiplied by the coefficient vector.
  • Differentiating the collocation solution yields sensitivities through the inverse system matrix.
  • The resulting derivatives depend on the chosen spline constraints and variable inputs.

Tags

Full text
# Cubic Spline Interpolation partial derivative to the point


# Cubic Spline Interpolation partial derivative to the point












Still didn't figure out this, so looking for some help, kindly apppreciated.

By this blog https://blog.timodenk.com/cubic-spline-interpolation/index.html, the piecewise cubic spline interpolation is implemented, and the interpolated value comes out as expected, it's no problem.

The problem is, I need to calculate the partial derivatives with respect to the two nearest point $z$ value, for example, the interpolated point is $(t, z)$, and the left point is $(t_1, z_1)$ and the right point is $(t_2, z_2)$, I need to calculate $\frac{\partial z}{\partial z_1}$ and $\frac{\partial z}{\partial z_2}$, and here is my steps:

There are $n+1$ data points $(t_i, z_i), for \ i = 1, 2, ..., n+1$.

There are $n$ cubic polynomial equations for each interval $[t_i, t_{i+1}], for \ i = 1, 2, ..., n$.

$z_i = a_i * t_i^3 + b_i * t_i^2 + c_i * t_i + d_i, for \ i = 1, 2, ..., n$

$z_{i+1} = a_i * t_{i+1}^3 + b_i * t_{i+1}^2 + c_i * t_{i+1} + d_i, for \ i = 1, 2, ..., n$

also, $z = a_i * t^3 + b_i * t^2 + c_i * t + d_i, t \in [t_i, t_{i+1}], for \ i = 1, 2, ..., n$

By the chain rule,

$\frac{\partial z}{\partial z_i} = \frac{\partial z}{\partial a_i} * \frac{\partial a_i}{\partial z_i} + \frac{\partial z}{\partial b_i} * \frac{\partial b_i}{\partial z_i} + \frac{\partial z}{\partial c_i} * \frac{\partial c_i}{\partial z_i} + \frac{\partial z}{\partial d_i} * \frac{\partial d_i}{\partial z_i} = t^3 / t_i^3 + t^2 / t_i^2 + t / t_i + 1$

$\frac{\partial z}{\partial z_{i+1}} = \frac{\partial z}{\partial a_i} * \frac{\partial a_i}{\partial z_{i+1}} + \frac{\partial z}{\partial b_i} * \frac{\partial b_i}{\partial z_{i+1}} + \frac{\partial z}{\partial c_i} * \frac{\partial c_i}{\partial z_{i+1}} + \frac{\partial z}{\partial d_i} * \frac{\partial d_i}{\partial z_{i+1}} = t^3 / t_{i+1}^3 + t^2 / t_{i+1}^2 + t / t_{i+1} + 1$

But the result way too far from correct, compared with linear on zero interpolation, so still try to figure where goes wrong ...

As to why calculating these paritial derivatives, that's because the sensitivity can be used to calculate DV01 later, so firstly these paritial derivatives supposed to be calculated.

## Answer by Attack68 (score 2)

https://quant.stackexchange.com/a/78564

In solving the coefficients of a spline you are solving a collocation equation (linear systemm).

In your case you are solving the equation,

$$ \mathbf{A(t) c} = \mathbf{\hat{z}} \quad \implies \quad \mathbf{c} = \mathbf{A(t)^{-1}\hat{z}} $$

where in this case, $\mathbf{\hat{z}} = [\mathbf{z}, \mathbf{v}]$, is a vector composed of the datasite $z_i$ values and some additional continuity and endpoint constraints, $v_i$ added into the linear system. Here $\mathbf{c}$ is a vector of the spline coefficients, i.e. $[a_1, b_1, c_1, d_1, a_2, b_2, ..]$

If you take an arbitrary t-value, $t^*$, this will have an associated spline value, $z^*$, according to:

$$ z^* = \mathbf{a}(t^*)^\mathbf{T} \mathbf{c} $$

where the $a_i$ values depend on the value of $t^*$ and between which breakpoints the value lies.

The partial derivatives with respect to $\mathbf{\hat{z}}$ (which contains the datasites) is:

$$ \frac{ \partial z^*}{\partial \mathbf{\hat{z}}} = \mathbf{a}(t^*)^\mathbf{T} \frac{\partial \mathbf{c}}{\partial\mathbf{\hat{z}} } = \mathbf{a}(t^*)^\mathbf{T} \mathbf{A(t)^{-1}} $$

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.