Natural Cubic Spline Problem - what do I do next? Related to this similar problem.
I am attempting to solve the following:

Find a natural cubic spline function whose knots are $-1$, $0$, and $1$ and that takes on the values $S(-1)=5$, $S(0)=7$, and $S(1)=9$.

Neither my textbook nor my class notes have been particularly helpful in showing me how to work out a cubic spline problem like this. What I have seen thus far has been very theoretical, and I have not been able to find a completely worked out problem, so after I get the equations set up, I do not know how to proceed. I know it's supposed to involve a matrix, but I don't know how to set it up.
This is what I have done so far (I have tried to model what I did off of the similar problem I referenced earlier):

Suppose the natural cubic spline function has the form $S(x) = \begin{cases} S_{1}(x),& x \in (-\infty,-1] \\
S_{2}(x),& x \in [-1,0]\\
S_{3}(x),& x \in [0,1]\\
S_{4}(x),& x \in [1,\infty).
\end{cases}$
Then, in order to meet the necessary conditions for it to be a natural cubic spline, we need to have
  
  
*
  
*$S_{1}(-1)=S_{2}(-1) = 5$
  
*$S_{1}^{\prime}(-1)=S_{2}^{\prime}(-1)$
  
*$S_{1}^{\prime\prime}(-1)=S_{2}^{\prime\prime}(-1) = 0$ (the $=0$ is the "natural" condition)
  
*$S_{2}(0)=S_{3}(0) = 7$
  
*$S_{2}^{\prime}(0)=S_{3}^{\prime}(0)$
  
*$S_{2}^{\prime\prime}(0)=S_{3}^{\prime\prime}(0)$
  
*$S_{3}(1)=S_{4}(1) = 9$
  
*$S_{3}^{\prime}(1)=S_{4}^{\prime}(1)$
  
*$S_{3}^{\prime\prime}(1)=S_{4}^{\prime\prime}(1) = 0$ (the $=0$ is the "natural condition)
  
  
  Now, from here, I formed the $S_{i}(x)=a_{i}x^{3}+b_{i}x^{2}+c_{i}x+d_{i}$, the $S_{i}^{\prime}(x)=3a_{i}x^{2}+2b_{i}x+c_{i}$, and $S_{i}^{\prime\prime}(x)=6a_{i}x+2b_{i}$ for $i = 1,2,3,4$. 
Plugging in some conditions, I found that $d_{2}=7$ and $d_{3}=7$. Also, I ended up with $c_{2}=c_{3}$, and a couple more not terribly interesting things.

At this point, I do not know how to proceed. I know I have to form a matrix, but in terms of the parameters I have here, I don't know what that matrix is supposed to look like or how big it is supposed to be.
Would somebody please tell me what to do next? And please don't ask me what I know about this or that, because honestly, I don't know anything. I'm extremely lost and frustrated to the point of tears.
 A: I think you can just forget about your $S_1(x)$ and $S_4(x)$. We only care about what's happening on the interval $[-1,1]$, so we only need your $S_2(x)$ and $S_3(x)$.
You have 8 unknowns -- your $a_i$, $b_i$, $c_i$, $d_i$ for $i=2,3$.
Now we do what you did -- we start writing down equations that express the desired continuity and interpolation properties of the spline. First the interpolation requirements:
\begin{align}
S_2(-1) = 5 \quad & \Longrightarrow  \quad -a_2 + b_2 - c_2 + d_2 = 5 \\
S_2(0) = 7  \quad & \Longrightarrow  \quad d_2 = 7 \\
S_3(0) = 7  \quad & \Longrightarrow  \quad d_3 = 7 \\
S_3(1) = 9 \quad & \Longrightarrow  \quad a_3 + b_3 + c_3 + d_3 = 9 
\end{align}
Then the requirement that the two segments join with $C_2$ continuity at $x=0$:
\begin{align}
S_2'(0) = S_3'(0)  \quad & \Longrightarrow  \quad c_2 = c_3 \\
S_2''(0) = S_3''(0)  \quad & \Longrightarrow  \quad b_2 = b_3
\end{align}
And finally the "natural" end conditions:
\begin{align}
S_2''(-1) = 0  \quad & \Longrightarrow  \quad -6a_2 +2b_2 = 0 \\
S_3''(1) = 0  \quad & \Longrightarrow  \quad 6a_3 +2b_3 = 0 
\end{align}
Notice that there are 8 of these equations. The equations are linear, so you should be able to solve them to get the 8 unknowns $a_2$, $b_2$, $c_2$, $d_2$, $a_3$, $b_3$, $c_3$, $d_3$.
You can write the equations in matrix form, using an $8 \times 8$ matrix, but this really isn't necessary, and it probably won't help you solve them. Just solve the equations however you want. High-school Gaussian elimination will work just fine, for example.
The approach you were taking would work, too, but you'd end up with 16 equations and 16 unknowns, which makes everything a lot more laborious.
