I work a lot with velocity data given on discrete, regular grids, and I frequently need to interpolate these data and use the interpolated result as the right-hand side of an ODE. (For a detailed description of the application, see https://doi.org/10.5194/gmd-13-5935-2020). Due to the application, I care about the number of continuous derivatives of my interpolation scheme, and I care about the location of any discontinuities.

I know that quadratic splines have continuous first derivative, and that cubic splines have continuous first and second derivatives. The discontinuities of the third derivative in cubic splines are located at the knots (at least in the implementations and descriptions that I have seen), and I had just assumed that the same would be the case for quadratic splines. However, to my surprise, I recently found that this doesn't seem to be the case.

As an illustration, I have prepared two figures.

The first figure shows 11 points with equally spaced x-values, random y-values, and interpolating cubic splines. The splines have been constructed with two different spline implementations: scipy.interpolate.UnivariateSpline (which is an object-oriented wrapper for FITPACK, according to the documentation), and with scipy.interpolate.make_interp_spline, which uses scipy.interpolate.BSpline. The resulting curves are identical to machine precision.

Furthermore, the first figure also contains the second derivative of the interpolating splines, and we observe (as expected) that these are piecewise linear functions. Hence, the third derivatives would be discontinuous (piecewise constant) functions. The locations of the discontinuities are indicated by the vertical dashed lines.

Cubic interpolating splines and their second derivatives

The second plot is a similar illustration, except with quadratic splines instead of cubic. Again, the interpolating quadratic splines have been created with two different implementations, and again they are identical to machine precision. This time I show the first derivatives, and they are (as expected for quadratic splines) piecewise linear, which means that the second derivatives would be discontinuous (piecewise constant) functions. However what surprised me a bit is that this time the discontinuities are not located at the knots, but at the midpoint between two knots. (Or maybe it's more precise to say that the knots themselves are located at the midpoints between the provided datapoints?)

Quadratic interpolating splines and their first derivatives

To finally get to the point, my question is if there is a particular reason why the discontinuities are located at the midpoints for quadratic splines, and if this is simply a choice made in both the tested implementations, or if it has to be this way?


1 Answer 1


For the cubic spline case, it appears the spline interpolation scheme is using the "not-a-knot" spline interpolation, which enforces the 3rd derivative continuity at the 2nd point and the next-to-last point. This is the reason why you did not see a 3rd derivative discontinuity at x=1 and x=9. For details about the "not-a-knot" spline, please refer to this link.

For the quadratic spline case, the result conforms to the standard quadratic B-spline curve interpolation. Basically, you have 11 points and therefore the resulting degree 2 B-spline will have 11 control points with only 9 segments. The joints of these 9 segments will not be at the location of your input points and this is why the discontinuities are "in between" your data points.

Please note that whether the spline's knot points (where the discontinuity will happen) will coincide with the data points depends on the interpolation scheme. For cubic spline interpolation, we can enforce that by adding two additional boundary conditions and the commonly-used natural spline and the "not-a-knot" spline both are doing this. If you don't add the two additional boundary conditions, then the resulting spline will have 11 control points with 8 segments only. After adding two additional boundary conditions, the resulting spline will have 13 control points with 10 segments (and therefore we can choose the knot values properly so that these 10 segments are all in between data points).

  • $\begingroup$ Thanks for your answer. You mention "the standard quadratic B-spline curve interpolation". Could you suggest a reference where I can read more about this? I have found many quite detailed descriptions of how to implement cubic splines, by choosing the boundary conditions and setting up a tri-diagonal equation system and so on, but I haven't found anything similar for quadratic splines. $\endgroup$
    – Tor
    Commented Jun 15, 2021 at 11:17
  • $\begingroup$ Any article that talks about B-spline curve interpolation in general will be a good reference as the content should be applicable for B-spline curve of any degree. $\endgroup$
    – fang
    Commented Jun 16, 2021 at 3:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .