# Location of discontinuities in cubic and quadratic splines

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.

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?)

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?