# Knot sequence for a natural cubic (B-)spline interpolant

say I am given $n+1$ data points $(x_i,y_i)$ with $0\leq i \leq n$ and $x_0 < x_1 < \dots < x_n$.

I want to interpolate these with a natural cubic spline $s(x)$ ($C_2$ continuous at knots and $s''=0$ at endpoints) using the $x_i$ as knots, where I want to write $s$ as a linear combination of $n+1$ b-splines: $$s(x) = \sum_{i=0}^n a_i B_i(x)$$

What is the exact knot sequence to use here? Because of the $C_2$ continuity I am fairly sure the inner knots will just be the simple knots $x_1, \dots, x_{n-1}$, it's the endpoints that make my head hurt. Since the order $k$ is 4 and I will get $m-k$ b-splines (where $m$ is the number of knots), this would mean that I have to add 4 knots to my sequence of $x_i$ values, and the most obvious way to do that would be $$(x_0, x_0, x_0, x_1, x_2, \dots, x_{n-1}, x_n, x_n, x_n)$$ The question is: will this yield $s''(x_0)=s''(x_n)=0$?

Note: What I actually want to do is calculate a cubic smoothing spline w.r.t. the given $n+1$ data points with the spline written as a lin. combination of $n+1$ basis splines, and in order to solve for the coefficient vector $(a_0,\dots,a_n)$ I first need to find the correct knot sequence, so that I can actually calculate the basis functions.

The natural cubic B-spline that interpolate $(n+1)$ points will be a B-spline with $m$ control points where $m=n+3$. Therefore, this B-spline will be written as

$$s(x)=\sum_{i=0}^{m-1}a_iB_i(x)$$

This B-spline will require $m+4=n+7$ knots. Therefore, in addition to the existing $(n+1)$ knots, you will need 6 more knots. Therefore, your knot sequence should be

$$(x_0,x_0,x_0,x_0,x_1,x_2,x_3,...,x_{n-1},x_n,x_n,x_n,x_n)$$

where you add $x_0$ 3 times to the start and $x_n$ 3 times to the end.

BTW, setting $s^{''}(x_0)=s^{''}(x_n)=0.0$ are the extra constraints you need to impose in order to solve the system matrix (since you only have $n+1$ data points but have $m=n+3$ control points to solve for). They are not really the consequence of the knot sequence you choose to use.

• yes, thank you for clarifying. That was also the knot sequence I got from the Curry Schoenberg Thm in deBoor's "Practical guide to splines", ie to have the b-splines form a partition of unity on the basic interval $[x_0, x_n]$ the start and endknot must have multiplicity equal to the order. – Lutz P. May 29 '16 at 15:31