00:01
In this problem, we have two questions.
00:04
And in each of them, we are given three data points.
00:07
And we will fit a cubic spline on these data points.
00:12
So let's do the first one.
00:15
X and y values.
00:17
3, 4, 6, 10, 15, 35.
00:23
And these roughly look like this.
00:30
So we are interested in these functions.
00:33
P1 and p2.
00:37
So we have p1 equal to a0 plus a1x plus a2x squared plus a3x cubed.
00:46
P2 equal to b0 plus b1x plus b2x squared plus b3x cubed.
00:57
So we have a's and b's as our unknowns.
01:00
So we have eight unknown parameters here.
01:02
And therefore, we need eight equations.
01:05
And these are as follows.
01:08
P1, 3 equal to 10.
01:12
P1, 4 equal to 15.
01:16
P2, 4 equal to 15.
01:21
P2, 6 equal to 35.
01:26
And we have the prime derivative equations.
01:30
P1 ' 4 equal to p2 ' 4.
01:35
P1' ' 4 equal to p2' ' 4.
01:41
P1' ' 3 equal to 0.
01:44
And p2' ' 6 equal to 0.
01:50
Now you may expand these equations and collect them into an array form using matrices, which i have already done.
01:59
So let me just write down the result.
02:03
We have a large matrix coming up.
02:06
We have 1, 1.
02:08
The rest of it is just zeros.
02:15
We have 3, 4, 0, 0, 1, 0, 0, 0.
02:24
We have 9, 16, 0, 0, 8, 2, 2, 0.
02:34
27, 64, 0, 0, 48, 24, 18, 0, 0, 0, 1, 1.
02:48
And the rest is 0.
02:50
We have 0, 0, 4, 6, minus 1, 0, 0, 0, 0, 0, 0, 16, 36, minus 8, minus 2, 0, 2, 0, 0, 64, 2, 16, minus 48, minus 24, 0, and 38.
03:23
Okay, this is the coefficient matrix.
03:26
And we have the unknowns, a0, a1, a2, a3, b0, b1, b2, and b3.
03:37
Now we have the input, 10, 15, 15, 35, and 0.
03:48
We can invert this matrix using, for instance, wolfram alpha, which is free and available to everyone...