I have the following program:
nknots = 4
x_i = [0, 1, 2, 3]
y_i = [1, np.exp(1), np.exp(2), np.exp(3)]
coeff = interpolate.make_interp_spline(x_i, y_i, bc_type="natural")
I want to construct a cubic spline using the knots whose coordinates are given by x_i and y_i arrays. However, I'm having a hard time obtaining all the coefficients. A cubic spline function has the following form:
y_i(x) = a + b*(x - x_i) + c*(x - x_i)^2 + d*(x - x_i)^3
When I do
print(coeff(x_i))
I get only the array of a values:
[ 1. 2.71828183 7.3890561 20.08553692]
However, I'm missing the arrays for the b, c, and d coefficients. How do I extract those? Or are there steps I'm missing? I read the scipy documentation on make_interp_spline but I didn't understand how to get the b, c and d coefficients.