# What is the relationship between cubic B-splines and cubic splines?

What is the relationship between cubic B-splines and cubic splines?

A cubic spline is just a string of cubic pieces joined together so that (usually) the joins are smooth. The argument values at which the joins occur are called "knots", and the collection of knots is called a "knot sequence" or "knot vector".

Let's take the knot sequence to be fixed, for a while. Then the set of all cubic splines (with these given knots) forms a vector space, and it turns out that some things called b-spline basis functions form a basis for this vector space. If you don't know anything about vector spaces, this just means that you can write any spline uniquely as a linear combination of these basis functions. When you write a spline curve as a linear combination of b-spline basis functions in this way, it's called a "b-spline". So, b-splines are not a new type of spline, they are simply a different way of expressing any existing spline, in much the same way that "XVI" is a different way of expressing the number sixteen. And the important point is that any piecewise polynomial (i.e. any spline) can be written as a b-spline.

The functions $$B_0$$, $$B_1$$, $$B_2$$, $$B_3$$ that you described are the pieces that are used to form basis functions in the special case of cubic splines with uniform knots. The word "uniform" just means that the knots are equally spaced, so, usually, they are taken to be integers ... 0,1,2,3,4,... The nice thing about uniform knots is that all the resulting basis functions have identical shape, so any one of them can be obtained just by translating one primary one (moving it to the left or right). And, because the knot spacing is so simple, it's easy to write down explicit formulas for these uniform basis functions.

This picture shows the graphs of your four functions:

Then, here, we focus on the interval $$[0,1]$$. The functions are labelled $$a$$, $$b$$, $$c$$, $$d$$, instead of $$B_0$$, $$B_1$$, $$B_2$$, $$B_3$$. \begin{align*} a(u) &= \tfrac16 u^3 \\ b(u) &= \tfrac16 \left( 1 + 3u + 3u^2 - 3u^3 \right) \\ c(u) &= \tfrac16 \left( 4 - 6u^2 + 3u^3 \right) \\ d(u) &= \tfrac16 \left( 1 - 3u + 3u^2 - u^3 \right) \end{align*}

To form any basis function, you shift these pieces and glue them together, as shown here:

A few simple calculations, using continuity, show that in fact $$h=2/3$$ and $$k=1/6$$. This composite curve is $$C_2$$. As I mentioned above, you can get any other (uniform) basis function by shifting this one to the right or left.

If the knots are not uniform, then the basis functions are much more complex, and people don't usually write out closed-form formulas for them. Instead, they are generated recursively by the deBoor-Cox algorithm, starting with degree zero and working upwards to higher degrees.

For more info, look here, especially at "unit 6", or here, or here.

• What you said it makes perfect sense to me but I still have a small gap. The cubic spline function can be written as the linear combination of the B_ks: $S_3(x)=\sum_k^N \phi_k B_k(x)$ where $B_ks$ are the basic functions that I described before and $\phi_k$ the control points. – user105627 Mar 5 '14 at 15:31
• I will consider a 1D problem. If the control points are known: i.e. $x_0=1,x_1=2,x_2=3,x_3=4$ and $\phi_0=0,\phi_1=2,\phi_2=4,\phi=2$. When I used my basis function I ended up with this $S_3(x)=0 \times (1-x^3)/6+2 \times (3x^3-6x^2+4)/6+4 \times (-3x^3+3x^2+3x_1)+2 \times x^3/6$. I expected that when I substitute x=1 i.e. S(1) it will give me $0$ because the $\phi_0=0$. Instead of zero I got 13/6. It happens to know how can I use the basis functions? – user105627 Mar 5 '14 at 15:32
• You are using knots 1,2,3,4. This means you are focussed on the interval $[2,3]$. But your "B" functions are designed for use on the interval $[0,1]$. You have to shift them to the right to get basis functions for $[2,3]$. See pictures. – bubba Mar 6 '14 at 0:31
• How did you recognised that the "B" functions are designed for use on the interval [0,1]? I have to focus on the interval [2,3] because 1 and 4 are the boundaries? – user105627 Mar 6 '14 at 11:17
• By graphing them. Look at the first graph in my answer. The nice pattern I want occurs on the interval $[0,1]$. I guess you have to know what you're looking for -- the shapes shown – bubba Mar 6 '14 at 12:05

## Splines as interpolating curves of minimal curvature

For curves with moderate curvature, the second derivative is a good proxy for the real curvature (inverse of the curvature radius).

A spline is the minimizer of the variational problem to interpolate a given set of points while minimizing the second derivative: $$y=\mathop{\arg\min}_{u\in H^2([a,b])}\int_a^b \|u''(x)\|_2^2\,dx\qquad\text{ s.t.}\qquad \begin{split} u(x_k)=x_k,\quad k=1,2,...,n\\a\le x_1<x_2<...<x_n\le b \end{split}$$ The solution is

1. piecewise cubic on intervals $[x_i,x_{i+1}]$,
2. linear on $[a,x_1]$ and $[x_n,b]$,
3. continuous up to the second derivative, and
4. has the general formula $$y(x)=a+bx+\sum_{k=1}^n c_k\, (x-x_k)_+^3$$

## B-Splines

The cubic B-spline (basis spline) centered at $x=0$ is

$$\beta_3(x)=\frac16\left[(x+2)_+^3-4\,(x+1)_+^3+6\,(x)_+^3-4\,(x-1)_+^3+(x-2)_+^3\right]$$

(graphic has wrong scaling, too high by a factor of 6)

which obviously invalidates that the function values at integers are only 0 and 1. But still it is a compactly supported, minimally so, spline function with nodes at the integers.

Locally, every cubic spline with integer nodes can be expressed as a linear combination $\sum_{k=m}^nc_k \beta_3(x-k)$ of B-splines.

## Bezier curves

Bezier curves, sometimes called Bezier splines, have the formula $$y(x)=(1-x)^3P_0+3(1-x)^2xC_0+3(1-x)x^2C_1+x^3P_1$$ for $x\in[0,1]$.

In the general spline context, they can be used to express one segment of a spline. Not every concatenation of such segments results in a spline, the continuity of first and second derivatives must be ensured.

The nice property of Bezier curves is that they can be evaluated as convex combinations of convex combinations of... If $[A,B]_x=(1-x)A+xB$ then $$y(x)=\Bigl[\bigl[\,[P_0,C_0]_x,[C_0,C_1]_x\,\bigr]_x,\,\bigl[\,[C_0,C_1]_x,[C_1,P_1]_x\,\bigr]_x\Bigr]_x$$

## Other parametrizations of cubic segments

Your basis functions, also over the interval $[0,1]$, take the values $$\begin{array}{|ccc|ccc|ccc|} B_k(x)&B'_k(x)&B''_k(x)&B_k(0)&B'_k(0)&B''_k(0)&B_k(1)&B'_k(1)&B''_k(1)\\ \hline \tfrac16(1-x)^3&-\tfrac12(1-x)^2&(1-x)&\tfrac16&-\tfrac12&1&0&0&0\\ \tfrac16(3x^3-6x^2+4)&\tfrac12(3x^2-4x)&(3x-2)&\tfrac23&0&-2&\tfrac16&-\tfrac12&1\\ \tfrac16(-3x^3+3x^2+3x+1)&\tfrac12(-3x^2+2x+1)&(-3x+1)&\tfrac16&\tfrac12&1&\tfrac23&0&-2\\ \tfrac16x^3&\tfrac12x^2&x&0&0&0&\tfrac16&\tfrac12&1 \end{array}$$ where one can see that values and derivatives at the $x=0$ match with those at $x=1$ in the next line. See update below for how to interpret this further.

Useful parametrizations are, in my opinion, $$y(x)=(1-x)\,y(0)+x\,y(1)-\tfrac16x(1-x)(2-x)\,y''(0)-\tfrac16x(1-x)(1+x)\,y''(1)$$ and $$y(x)=(1-x)^2(1+2x)\,y(0)+x^2(3-2x)\,y(1)+x(1-x)^2y'(0)-x^2(1-x)y'(1)$$

Update: Per bubbas answer above, I now see that the $B_k$ are the pieces of the cubic basis spline $β_3(x)$. So for $x\in[0,1]$, \begin{align} d(x)=B_0(x)&=\beta_3(x+1)=\tfrac16 \beta_3(-1-x)=\tfrac16 [(1-x)^3]\\ c(x)=B_1(x)&=\beta_3(x\quad\;\,)=\tfrac16 [(x+2)^3-4(x+1)^3-6x^3]=\tfrac16 [3x^3-6x^2+4]\\ b(x)=B_2(x)&=\beta_3(x-1)=\tfrac16 [(x+1)^3-4x^3]=\tfrac16 [-3x^3+3x^2+3x+1]\\ a(x)=B_3(x)&=\beta_3(x-2)=\tfrac16 [x^3]\\ \end{align}

• I found that the basis functions are: $B_0$ – user105627 Mar 5 '14 at 9:21
• $B_0$ or $\beta_0$ usually refers to the rectangular box functions, either $1\!\!1_{[-1/2,1/2)}$ or $1\!\!1_{[0,1)}$. There is nothing cubic about them. Or did you mean the cubic B-spline centered about 0? – Dr. Lutz Lehmann Mar 5 '14 at 9:34
• Thanks for your response. What do you mean with function values (...,0,0,1,0,0,..)? Cubic spline has any function value? Every cubic spline can be expressed as $S_3(u)= \sum_{k=0}^N a_k B_k(u)$ where $B_k(u)$ are B-splines? The basis functions of B-splines I found that are as follows: $B_0(u)=(1-u)^3/6$, $B_1(u)=(3u^£-6u^2+4)/6$, $B_2(u)=(-3u^3+3u^2+3u+1)/6$, $B_3(u)=u^3/6$. These basis functions are standard right? – user105627 Mar 5 '14 at 9:39
• This I do not understand. I know of Bezier splines that are constructed with control points as $(1-x)^3P_0+3(1-x)^2xC_0+3(1-x)x^2C_1+x^3P_1$. Which in reality is just a way to describe a curve that is cubic in each component. A spline is defined by the way that these single cubic pieces are spliced together. B-splines are basis splines, $β_0$ the box function and the others result from convolution, $β_{k+1}=β_k*β_0$. So that $β_1$ is the witch hat,... – Dr. Lutz Lehmann Mar 5 '14 at 9:50
• > This I do not understand. Take a uniform knot sequence like $\ldots, -2, -1, 0, 1, 2, 3, \ldots$, and form the corresponding b-spline basis functions of degree 3. By using the deBoor-Cox recurrence formula, for example, or "convolution", if you like. Among these basis functions, look at the four that are non-zero on the interval $[0,1]$. You will find that their values on $[0,1]$ are given by the four polynomials $B_0, B_1, B_2, B_3$. These polynomials are somewhat similar to the Bernstein polynomials used to construct Bezier curves, but not quite the same. – bubba Mar 7 '14 at 4:48