Solution (source code)

= Solution
{c}

Let $M_j=s''(j)$. A <natural cubic spline> has $M_0=M_2=0$. The interior spline equation on equal unit intervals is
$$
M_0+4M_1+M_2=6[(4-0)-(0-0)]=24,
$$
so $M_1=6$. The standard second-derivative interpolation formula, or direct integration of the linear second derivative, gives
$$
\boxed{s(x)=
\begin{cases}
x^3-x,&0\leq x\leq1,\\
-x^3+6x^2-7x+2,&1\leq x\leq2.
\end{cases}}
$$
The two pieces have equal value, first derivative, and second derivative at one, and $s''$ vanishes at zero and two.

Adding the linear function $x$ changes the nodal data by $(0,1,2)$ without affecting second derivatives. By uniqueness, the second requested natural cubic spline is \b[$s(x)+x$], with pieces $x^3$ and $-x^3+6x^2-6x+2$ respectively.