Subjects numerical analysis

Natural Cubic Spline

Step-by-step solutions with LaTeX - clean, fast, and student-friendly.

Search Solutions

Natural Cubic Spline


1. **State the problem:** We are given data points $(x, f(x))$ as $(25,5)$, $(36,6)$, $(49,7)$, $(64,8)$, and $(81,9)$. We want to construct a natural cubic spline that fits these points and then use it to estimate $f(55)$. 2. **Set up the spline intervals:** The spline is piecewise cubic on intervals $[25,36]$, $[36,49]$, $[49,64]$, and $[64,81]$. Let the spline on interval $[x_i, x_{i+1}]$ be $S_i(x) = a_i + b_i(x - x_i) + c_i(x - x_i)^2 + d_i(x - x_i)^3$ for $i=1,2,3,4$. 3. **Calculate the step sizes:** $$h_1 = 36 - 25 = 11, \quad h_2 = 49 - 36 = 13, \quad h_3 = 64 - 49 = 15, \quad h_4 = 81 - 64 = 17.$$ 4. **Set up the system for second derivatives:** For natural cubic splines, the second derivatives at the endpoints are zero: $S_1''(25) = 0$ and $S_4''(81) = 0$. 5. **Calculate the right-hand side vector $\alpha$ for the system:** For $i=2,3,4$, $$\alpha_i = \frac{3}{h_i}(f(x_{i+1}) - f(x_i)) - \frac{3}{h_{i-1}}(f(x_i) - f(x_{i-1})).$$ Calculate: $$\alpha_2 = \frac{3}{13}(7 - 6) - \frac{3}{11}(6 - 5) = \frac{3}{13} - \frac{3}{11} = 0.2308 - 0.2727 = -0.0419,$$ $$\alpha_3 = \frac{3}{15}(8 - 7) - \frac{3}{13}(7 - 6) = \frac{3}{15} - \frac{3}{13} = 0.2 - 0.2308 = -0.0308,$$ $$\alpha_4 = \frac{3}{17}(9 - 8) - \frac{3}{15}(8 - 7) = \frac{3}{17} - \frac{3}{15} = 0.1765 - 0.2 = -0.0235.$$ 6. **Set up the tridiagonal system for $c_i$ (second derivatives):** For $i=2,3,4$, $$h_{i-1} c_{i-1} + 2(h_{i-1} + h_i) c_i + h_i c_{i+1} = \alpha_i,$$ with $c_1 = 0$ and $c_5 = 0$ (natural spline boundary conditions). The system is: $$11 c_1 + 2(11+13) c_2 + 13 c_3 = -0.0419,$$ $$13 c_2 + 2(13+15) c_3 + 15 c_4 = -0.0308,$$ $$15 c_3 + 2(15+17) c_4 + 17 c_5 = -0.0235,$$ with $c_1=0$ and $c_5=0$. Simplify: $$0 + 48 c_2 + 13 c_3 = -0.0419,$$ $$13 c_2 + 56 c_3 + 15 c_4 = -0.0308,$$ $$15 c_3 + 64 c_4 + 0 = -0.0235.$$ 7. **Solve the system:** From the first equation: $$48 c_2 = -0.0419 - 13 c_3 \Rightarrow c_2 = \frac{-0.0419 - 13 c_3}{48}.$$ Substitute into the second: $$13 \left(\frac{-0.0419 - 13 c_3}{48}\right) + 56 c_3 + 15 c_4 = -0.0308.$$ Multiply both sides by 48: $$13(-0.0419 - 13 c_3) + 56 \times 48 c_3 + 15 \times 48 c_4 = -0.0308 \times 48,$$ $$-0.5447 - 169 c_3 + 2688 c_3 + 720 c_4 = -1.4784,$$ $$(2688 - 169) c_3 + 720 c_4 = -1.4784 + 0.5447,$$ $$2519 c_3 + 720 c_4 = -0.9337.$$ From the third equation: $$15 c_3 + 64 c_4 = -0.0235.$$ Solve the two equations: $$2519 c_3 + 720 c_4 = -0.9337,$$ $$15 c_3 + 64 c_4 = -0.0235.$$ Multiply the second by 45. $$675 c_3 + 2880 c_4 = -1.0575.$$ Multiply the first by 4: $$10076 c_3 + 2880 c_4 = -3.7348.$$ Subtract: $$(10076 - 675) c_3 = -3.7348 + 1.0575,$$ $$9361 c_3 = -2.6773,$$ $$c_3 = -0.000286.$$ Substitute back: $$15(-0.000286) + 64 c_4 = -0.0235 \Rightarrow -0.00429 + 64 c_4 = -0.0235,$$ $$64 c_4 = -0.01921 \Rightarrow c_4 = -0.0003.$$ Substitute $c_3$ into $c_2$: $$c_2 = \frac{-0.0419 - 13(-0.000286)}{48} = \frac{-0.0419 + 0.00372}{48} = \frac{-0.03818}{48} = -0.000795.$$ 8. **Calculate $b_i$ and $d_i$ coefficients:** For $i=1,2,3,4$, $$b_i = \frac{f(x_{i+1}) - f(x_i)}{h_i} - \frac{h_i}{3}(2 c_i + c_{i+1}),$$ $$d_i = \frac{c_{i+1} - c_i}{3 h_i}.$$ Recall $c_1 = 0$, $c_5 = 0$. Calculate $b_3$ and $d_3$ for interval $[49,64]$ since $55$ lies here: $$b_3 = \frac{8 - 7}{15} - \frac{15}{3}(2 \times (-0.000286) + (-0.0003)) = \frac{1}{15} - 5(-0.000572 - 0.0003) = 0.0667 + 0.00436 = 0.0711,$$ $$d_3 = \frac{-0.0003 - (-0.000286)}{3 \times 15} = \frac{-0.000014}{45} = -3.11 \times 10^{-7}.$$ 9. **Calculate $a_3$:** $$a_3 = f(49) = 7.$$ 10. **Estimate $f(55)$:** $$x = 55, \quad x - 49 = 6,$$ $$S_3(55) = a_3 + b_3 (6) + c_3 (6)^2 + d_3 (6)^3,$$ $$= 7 + 0.0711 \times 6 + (-0.000286) \times 36 + (-3.11 \times 10^{-7}) \times 216,$$ $$= 7 + 0.4266 - 0.0103 - 0.000067 = 7.4162.$$ **Final answer:** The estimated value is $\boxed{7.42}$ at $x=55$ using the natural cubic spline.