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.