2. Calculate Cubic Splines y(1.5)
Solution:
Cubic spline formula is
`f(x)=(x_i-x)^3/(6h) M_(i-1) + (x-x_(i-1))^3/(6h) M_i + ((x_i-x))/h (y_(i-1)-h^2/6 M_(i-1)) + ((x-x_(i-1)))/h (y_i-h^2/6 M_i) ->(1)`
We have, `M_(i-1)+4M_(i)+M_(i+1)=6/h^2(y_(i-1)-2y_(i)+y_(i+1))->(2)`
Here `h=1,n=3`
`M_0=0,M_3=0`
Substitute `i=1` in equation `(2)`
`M_0+4M_1+M_2=6/h^2(y_0-2y_1+y_2)`
`=>0+4M_1+M_2=6/1*(0-2*1+0)`
`=>4M_1+M_2=-12`
Substitute `i=2` in equation `(2)`
`M_1+4M_2+M_3=6/h^2(y_1-2y_2+y_3)`
`=>M_1+4M_2+0=6/1*(1-2*0+1)`
`=>M_1+4M_2=12`
Solving these 2 equations using elimination method
Total Equations are `2`
`4M_1+M_2=-12 -> (1)`
`M_1+4M_2=12 -> (2)`
Select the equations `(1)` and `(2)`, and eliminate the variable `M_1`.
`4M_1+M_2=-12` | ` xx 1->` | | `` | `4M_1` | `+` | `M_2` | `=` | `-12` | `` |
| | − | |
`M_1+4M_2=12` | ` xx 4->` | | `` | `4M_1` | `+` | `16M_2` | `=` | `48` | `` |
| | |
|
| | | | | `-` | `15M_2` | `=` | `-60` | ` -> (3)` |
Now use back substitution method
From (3)
`-15M_2=-60`
`=>M_2=(-60)/(-15)=4`
From (2)
`M_1+4M_2=12`
`=>M_1+4(4)=12`
`=>M_1+16=12`
`=>M_1=12-16=-4`
Solution using Elimination method.
`M_1=-4,M_2=4`
Substitute `i=1` in equation `(1)`, we get cubic spline in `1^(st)` interval `[x_0,x_1]=[1,2]`
`f_1(x)=(x_1-x)^3/(6h) M_0 + (x-x_0)^3/(6h) M_1 + ((x_1-x))/h (y_0-h^2/6 M_0)+((x-x_0))/h (y_1-h^2/6 M_1)`
`f_1(x)=(2-x)^3/6 *0 + (x-1)^3/6 *-4 + ((2-x))/1 (0-1/6 *0) + ((x-1))/1 (1-1/6 *-4)`
`f_1(x)=1/3(-2x^3+6x^2-x-3)`, for `1<=x<=2`
Substitute `i=2` in equation `(1)`, we get cubic spline in `2^(nd)` interval `[x_1,x_2]=[2,3]`
`f_2(x)=(x_2-x)^3/(6h) M_1 + (x-x_1)^3/(6h) M_2 + ((x_2-x))/h (y_1-h^2/6 M_1)+((x-x_1))/h (y_2-h^2/6 M_2)`
`f_2(x)=(3-x)^3/6 *-4 + (x-2)^3/6 *4 + ((3-x))/1 (1-1/6 *-4) + ((x-2))/1 (0-1/6 *4)`
`f_2(x)=1/3(4x^3-30x^2+71x-51)`, for `2<=x<=3`
Substitute `i=3` in equation `(1)`, we get cubic spline in `3^(rd)` interval `[x_2,x_3]=[3,4]`
`f_3(x)=(x_3-x)^3/(6h) M_2 + (x-x_2)^3/(6h) M_3 + ((x_3-x))/h (y_2-h^2/6 M_2)+((x-x_2))/h (y_3-h^2/6 M_3)`
`f_3(x)=(4-x)^3/6 *4 + (x-3)^3/6 *0 + ((4-x))/1 (0-1/6 *4) + ((x-3))/1 (1-1/6 *0)`
`f_3(x)=1/3(-2x^3+24x^2-91x+111)`, for `3<=x<=4`
For `y(1.5)`, `1.5 in [1,2]`, so substitute `x=1.5` in `f_1(x)`, we get
`f_1(1.5)=0.75`
This material is intended as a summary. Use your textbook for detail explanation.
Any bug, improvement, feedback then