An archived instance of discourse for discussion in undergraduate Real and Numerical Analysis.

Exam Review

Cheryl

Problem $8c$ on our review sheet, it asks:
Consider the data $(-1,0), (1,1), (2,2)$. Write down a system of linear equations that the natural cubic spline that fits this data must satisfy.
What did you come up with and how?

Invictus

I took the points and placed them on a number line and came up with 3 nodes so I needed an equation for each section so 2.

$f_1(x) = a_1x^3 + b_1x^2 + c_1x + d_1$
$f_2(x) = a_2x^3 + b_2x^2 + c_2x + d_2$

Since there are 8 unknowns we need 8 equations, I started out by using the points:

$f_1(-1) = 0$
$-a_1 + b_1 - c_1 +d_1 = 0$

$f_1(1) = 1$
$a_1 + b_1 +c_1 + d_1 = 1$

$f_2(1) = 1$
$a_2 + b_2 +c_2 + d_2 = 1$

$f_2(2) = 2$
$8a_2 + 4b_2 + 2c_2 + d_2 = 2$

Then since you know the two equations have to be the same in the middle you can do:

$f_1(1) = f_2(1)$
$a_1 + b_1 +c_1 + d_1 = a_2 + b_2 +c_2 + d_2$

In order to get the last three we have to look at the derivatives. Since this is a natural spline the derivatives at the end points have to be 0 and the intersecting slopes have to be the same:

$f_1'(x) = 3a_1x^2 + 2b_1x + c_1$
$f_2'(x) = 3a_2x^2 + 2b_2x + c_2$

$f_1'(-1) = 0$
$3a_1 - 2b_1 + c_1 = 0$

$f_2'(2) = 0$
$12a_2 + 4b_2 + c_2 = 0$

$f_1'(1) = f_2'(1)$
$3a_1x + 2b_1 + c_1 = 3a_2 + 2b_2 + c_2$

Then you would just use these equations to create a matrix.

hjoseph

I got very similar results but I believe you made 2 mistakes computing the $2nd$ derivatives to make this a natural cubic spline. I got $f_1^{''}(x) = 6a_1x + 2b_1$ which means $f_1^{''}(-1) = -6a_1 + 2b_1 = 0$ and for $f_2$ I got $f_2^{''}(x) = -6a_2x + 2b_1$ which means $f_2^{''}(2) = 12a_2 + 2b_2 = 0$. This could also be due to my own error though.

Invictus

You are right it is the second derivative that is 0 at the end points not the first.