Why is the middle segment of a 4 points cubic spline not matching a 100 points cubic spline?

37 Views Asked by At

Let's say I have x0, x1, ..., x99 and y0, y1, ..., y99

X = (x0, ..., x99)
Y = (y0, ..., y99)

X_ = (x0, ..., x3)
Y_ = (y0, ..., y3)

S = CubicSpline(X, Y)
S_ = CubicSpline(X_, Y_)

I expect S and S_ to be exactly match between x1 and x2, but they are different in my code. I'm not here to ask coding questions. I just want to make sure are they supposed to be different?

My code uses scipy's CubicSpline function in the interpolation package, if you need to know which tool I'm using.

1

There are 1 best solutions below

0
On

Between $x_0$ and $x_3$ there are 3 different cubic pieces (12 unknowns). If they join continuously up to the 2nd derivative that's 6 constraints, and the values $y_0,...,y_3$ adds 4 constraints. You need 2 more constraints for a unique solution, and usually they are chosen to minimize some measure of variation of the curve, which will be affected by any of the values.