Skip to main content
1 of 4
Jukka Kohonen
  • 4.2k
  • 2
  • 21
  • 49

It depends on what level of smoothness you require at your knots. The question only says that the spline has to interpolate data (= each piece must match the given values at the two knots that it connects). But when people say cubic spline, they usually mean that at each internal knot, the two pieces also have matching 1st and 2nd derivatives. But more generally you could require less smoothness, so let's consider three cases.

Suppose you have $n+1$ knots, thus $n$ pieces connecting them. (Since the question talks about "time", I am assuming that the final knot does not come back to the initial knot, that is, our spline does not form a closed loop.) You have $n-1$ internal knots (each between two adjacent pieces).

Without constant term, for each $i=1,\ldots,n$, the $i$th piece has 3 free parameters $b_i, c_i, d_i$, for a total of $3n$ parameters.

  1. If no smoothness required: Each of the $n$ pieces must match both knots at its ends, so you have $2n$ conditions. Your $3n$ free parameters are ample and solutions should exist.

  2. If you require first derivatives to match at internal knots, that is $n-1$ more conditions. You now have $3n-1$ conditions, still less than your $3n$ free parameters, so it should be possible. Your "cubic spline" has no corners at the knots (since first derivatives match), but its curvature will in general change abruptly (since second derivatives need not match). This may not be what you mean by "cubic spline".

  3. If you require first and second derivative to match at the $n-1$ internal knots, you have $2n + 2(n-1) = 4n-2$ conditions, which is more than $3n$ (for $n>2$). You have more conditions than free parameters, so in general solutions will not exist. (They might exist in special cases.)

The usual definition has four parameters per piece, so $4n$ parameters total, which leaves 2 extra degrees of freedom even after matching first and second derivatives ($4n-2$ conditions). The usual way to use up these 2 dof is to impose that at the first and last knots, the second derivative vanishes (so called "natural" cubic spline).

Jukka Kohonen
  • 4.2k
  • 2
  • 21
  • 49