use and show matlab file
3c only
algorithm 3.4
3. Construct the natural cubic spline for the following data. a. b. c. d.
To construct the cubic spline interpolant S for the function f, defined at the numbers x0?<x1?<?<xn?, satisfying S??(x0?)=S??(xn?)=0 : INPUT n:x0?,x1?,…,xn?:a0?=f(x0?),a1?=f(x1?),…,an?=f(xn?). OUTPUT aj?,bj?,cj?,dj? for j=0,1,…,n?1. (Note: S(x)=Sj?(x)=aj?+bj?(x?xj?)+cj?(x?xj?)2+dj?(x?xj?)3 for xj??x?xj+1?.) Step 1 For i=0,1,…,n?1 set hi?=xi+1??xi?. Step 2 For i=1,2,…,n?1 set ?i?=hi?3?(ai+1??ai?)?hi?1?3?(ai??ai?1?). Step 3 Set l0?=1; (Steps 3, 4, and 5 and part of Step 6 solve a tridiagonal linear system using a method described in Algorithm 6.7.) ?0?=0;z0?=0.? Step 4 For i=1,2,…,n?1 set li??i?zi??=2(xi+1??xi?1?)?hi?1??i?1?=hi?/li?=(?i??hi?1?zi?1?)/li?? Step 5 Set In?=1; zn?=0;cn?=0.? Step 6 For j=n?1,n?2,…,0 set cj?bj?dj??=zj???j?cj+1?:=(aj+1??aj?)/hj??hj?(cj+1?+2cj?)/3;=(cj+1??cj?)/(3hj?).? Step 7 OUTPUT (aj?,bj?,cj?,dj? for j=0,1,…,n?1); STOP.