7
$\begingroup$

Good morning,

I want to learn more about cubic splines but unfortunately my class goes pretty quickly and we really only get the high level overview of why they're important and why they work.

To me it's clear why we dont use linear functions, we cant differentiate the spline at the points we have to interpolate. Due to this, we lose important information about the underlying function.

But now this is where it gets harder for me. I know we can't use hermite polynomials because we require the derivative and many times we dont have this information available to us.

So we could use quadratic polynomials between each point to approximate it so its smooth on the points and we can differentiate it. The book goes on to state

The difficulty arises because we generally need to specify conditions about the derivative of the interpolant at the endpoints $x_0$ and $x_n$. [In quadratic polynomials] there is not sufficient number of constants to ensure that condition will be satisfied.

How does the number of constant bear anything on the endpoint constraints? A quadratic polynomial is twice differentiable. Can anyone fill me in on gap I have here in my knowledge of why we need cubic splines?

thank you!

$\endgroup$
1
  • $\begingroup$ What book are you using? $\endgroup$
    – bubba
    Nov 6, 2014 at 11:12

5 Answers 5

14
$\begingroup$

A quadratic polynomial $y=ax^2+bx+c$ has only three "degrees of freedom" ($a,b,c$). Thus if you want your quadratic function to run through two points, you have already only one degree of freedom left. If you want to prescribe the slope at one of the two points, this already uses up the last degree of freedom, thus leaving no choice for the slope at the other end, for example. A cubic polynomial $y=ax^3+bx^2+cx+d$ has four degrees of freedom, thus allowing to prescribe a total of four conditions, such as passing through two points and having specific slopes at two points.

Admittedly, with splines the situation is different - but only slightly: We may view both $x$ and $y$ as cubic functions of a parameter $t$, and what we want is indeed not just the directions to match (with neighbouring spline segments, say) at the endpoints, but in fact also the "speed", so the parametrization cannot be ignored. Thus we want a total of 8 conditions to hold ($x$ at $t=0$, $y$ at $t=0$, $x$ at $t=1$, $y$ at $t=1$ and the same for the derivatives with respect to $t$).

Maybe the most instructive argument is to really join a few quadratic splines that match only in endpoints and tangent directions. The sudden change in curvature is noticeable (either by the eye or by the passenger of a rollercoaster constructed this way). - As an extreme example: you cannot join ends with a single quadratic spline if they point in opposite directions (i.e. if you need a point of inflexion)

$\endgroup$
9
$\begingroup$

Well, actually, you can use quadratic splines for many purposes. They are used to design TrueType fonts, for example.

To construct a quadratic spline, you proceed as follows. Suppose you have $n$ data items to interpolate (maybe $n$ points, or $n-2$ points and 2 end derivatives). Then we need a spline with $n$ control points (and therefore $n$ degrees of freedom). If a quadratic b-spline has $n$ control points, then it must have $n+3$ knots. To ensure interpolation of the first and last data points, the knot sequence should start with $(0,0,0)$ and should end with $(1,1,1)$. Then you need $n-3$ interior knots. Choosing these is a bit tricky, but it can be done. Then you set up a system of linear equations, and solve to get the control points.

The resulting curve will be $C_1$, which may be good enough for your needs.

Here is an example with $n=5$.

enter image description here

The blue points are the ones that were interpolated, and the red points are the calculated control points. The hollow (white points) indicate the places where the quadratic segments join together, sometimes called knot points. The spline is a little strange because the knot points do not coincide with the interpolated points, as they would on a cubic spline. This spline has a knot sequence $(0,0,0, 0.3, 0.7, 1,1,1)$.

Cubics become valuable when you start to do 3D work. Quadratic segments are always planar; cubic segments are the lowest degree ones that can be "twisted" in space (i.e. non-planar).

People who design car exteriors generally frown on cubic splines. They like to use Bezier curves, which you can think of as splines that have only a single segment. They typically use degrees up to around 6 or 7.

$\endgroup$
6
$\begingroup$

For a curve to be continuous, the functions must be equal where the segments meet - $f_i(x_i) = f_{i-1}(x_{i-1})$. A first order - linear - spline may be continuous, but it won't be smooth unless the points are all collinear.

If you want the curve to be smooth, then you need the slope of the curves - the first derivatives - to be equal, so $f'_i(x_i) = f'_{i-1}(x_{i-1})$.

For the curve segments to have the same curvature where they meet, the rate of change of the slopes of the curves must be the same, thus $f''_i(x_i) = f''_{i-1}(x_{i-1})$.

For a general quadratic equation, you can ensure the first and second conditions, but you cannot ensure the final condition because the second derivative, $F''(x) = 2A$, is a constant. The condition can be met only if all of the points lie along the same parabola.

Cubic - and higher order - splines can satisfy all three conditions.

Note that using higher order equations will provide even smoother curves at the expense of additional derivatives, but the differences rapidly become more subtle; cubic splines are generally sufficient.

$\endgroup$
3
$\begingroup$

The two most important reasons to use cubic splines instead of quadratic:

  • Cubic splines are C2-continuous, which is handy sometimes
  • Quadratic splines "ring" a lot. If you move one of the data points, it will make big changes to the whole curve all the way out to the ends. With cubic splines, if you move one of the data points the perturbations along the rest of the curve drop off quickly and decay exponentially -- with each point further away from the one you moved, the size of the change is multiplied by -0.268. (good luck finding that written down in an authoritative text, but it's true!)
$\endgroup$
8
  • $\begingroup$ «exponentially» is not a good way to descrbe this :-) $\endgroup$ Jan 28, 2016 at 5:16
  • $\begingroup$ @MarianoSuárez-Alvarez, changed to "decay exponentially", which is accurate $\endgroup$ Jan 28, 2016 at 5:25
  • $\begingroup$ I can't believe that you get exponential decay of displacement for cubics and not for quadratics. $\endgroup$ Jan 28, 2016 at 5:27
  • $\begingroup$ @MarianoSuárez-Alvarez it's true. For cubics I show it constructively here: nbviewer.jupyter.org/github/mtimmerm/IPythonNotebooks/blob/… . Applying similar methods to generate a piecewise quadratic kernel doesn't provide the decay (unless I made a mistake. I didn't follow the quadratics far enough to check my work rigorously) $\endgroup$ Jan 28, 2016 at 5:31
  • $\begingroup$ I checked -- displacements definitely do not decay in quadratic splines. $\endgroup$ Jan 28, 2016 at 6:09
2
$\begingroup$

Cubic spline is popular because it is the lowest degree that allows separate control on the two end points and two end derivatives and it is also the lowest degree that allows inflection points.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.