Page155Q.28Theupperportionofthisnoblebeastistobeapproximatedusingclampedcubicsplineinterpolants.Thecurveisdrawnonagridfromwhichthetableisconstructed.UseAlgorithm3.5toconstructthethreeclampedcubicsplines.Solution:Thethreeclampedsplineshaveequationsoftheform32()()()()iiiiiiiixaxxcxxxsbdxforxin1[,,]iixxwherethevaluesofthecoefficientsaregiveninthefollowingtables.Spline1xix()iiafxibicid()ifx013.01.0000-0.34680.04681.0123.70.4468-0.20640.0266253.9-0.07450.03260.3419364.21.01631.0582-0.5745475.71.4091-0.66540.1563586.60.5472-0.19650.02396107.10.0485-0.0529-0.00267136.7-0.3381-0.07590.005705101520253033.544.555.566.577.58174.5-0.67Spline2xix()iiafxibicid()ifx0174.53.0000-1.10070.12623.01207.0-0.19790.0348-0.02292236.1-0.6085-0.17160.28013245.6-0.11140.6688-0.35744255.80.1540-0.40340.08825275.2-0.40120.1258-2.5680627.74.1-4.0Spline3xix()iiafxibicid()ifx027.74.10.33002.2620-3.79940.331284.30.6614-1.15740.29602294.1-0.7653-0.2693-0.06533303.0-1.5functionp155q28clearallx1=[125678101317]';fx1=[3.03.73.94.25.76.67.16.74.5];fxp1=[1.0-0.67]';x2=[17202324252727.7]';fx2=[4.57.06.15.65.85.24.1];fxp2=[3.0-4.0]';x3=[27.7282930]';fx3=[4.14.34.13.0];fxp3=[0.33-1.5]';c=csi(x1,fx1,fxp1)n=size(c,2);nn=n-1;nii=11;m1=nn*nii;forj=1:nnforii=1:niix((j-1)*nii+ii)=x1(j)+(ii-1)*(x1(j+1)-x1(j))/nii;s((j-1)*nii+ii)=c(1,j)+c(2,j)*(x((j-1)*nii+ii)-x1(j))+...+c(3,j)*(x((j-1)*nii+ii)-x1(j))^2+c(4,j)*(x((j-1)*nii+ii)-x1(j))^3;endendc=csi(x2,fx2,fxp2)n=size(c,2);nn=n-1;nii=11;m2=nn*nii;forj=1:nnforii=1:niix(m1+(j-1)*nii+ii)=x2(j)+(ii-1)*(x2(j+1)-x2(j))/nii;s(m1+(j-1)*nii+ii)=c(1,j)+c(2,j)*(x(m1+(j-1)*nii+ii)-x2(j))+...+c(3,j)*(x(m1+(j-1)*nii+ii)-x2(j))^2+c(4,j)*(x(m1+(j-1)*nii+ii)-x2(j))^3;endendc=csi(x3,fx3,fxp3)n=size(c,2);nn=n-1;nii=11;m3=nn*nii;forj=1:nnforii=1:niix(m1+m2+(j-1)*nii+ii)=x3(j)+(ii-1)*(x3(j+1)-x3(j))/nii;s(m1+m2+(j-1)*nii+ii)=c(1,j)+c(2,j)*(x(m1+m2+(j-1)*nii+ii)-x3(j))+...+c(3,j)*(x(m1+m2+(j-1)*nii+ii)-x3(j))^2+c(4,j)*(x(m1+m2+(j-1)*nii+ii)-x3(j))^3;endendplot(x,s)functionc=csi(x,fx,fxp)n=size(x,1);h=zeros(n-1,1);alpha=zeros(n,1);z=alpha;l=z;mu=h;c=zeros(4,n);fori=1:n-1h(i)=x(i+1)-x(i);endalpha(1)=3*(fx(2)-fx(1))/h(1)-3*fxp(1);alpha(n)=3*fxp(2)-3*(fx(n)-fx(n-1))/h(n-1);fori=2:n-1alpha(i)=3*(fx(i+1)-fx(i))/h(i)-3*(fx(i)-fx(i-1))/h(i-1);endl(1)=2*h(1);mu(1)=0.5;z(1)=alpha(1)/l(1);fori=2:n-1;l(i)=2*(x(i+1)-x(i-1))-h(i-1)*mu(i-1);mu(i)=h(i)/l(i);z(i)=(alpha(i)-h(i-1)*z(i-1))/l(i);endl(n)=h(n-1)*(2-mu(n-1));z(n)=(alpha(n)-h(n-1)*z(n-1))/l(n);c(3,n)=z(n);forj=n-1:-1:1c(3,j)=z(j)-mu(j)*c(3,j+1);c(2,j)=(fx(j+1)-fx(j))/h(j)-h(j)*(c(3,j+1)+2*c(3,j))/3;c(4,j)=(c(3,j+1)-c(3,j))/(3*h(j));c(1,j)=fx(j);endEndofQuestion28onPage155SeenextpagePage155Q.29RepeatExercise28,exceptconstructthreenaturalsplinesusingAlgorithm3.4.Thethreenaturalsplineshaveequationsoftheform32()()()()iiiiiiiixaxxcxxxsbdxforxin1[,,]iixxwherethevaluesofthecoefficientsaregiveninthefollowingtables.Spline1xix()iiafxibicid013.00.78570.0000-0.0857123.70.5286-0.25710.0344253.9-0.08580.05230.3335364.21.01941.0529-0.5723475.71.4083-0.66400.1557586.60.5474-0.19690.02416107.10.0491-0.0522-0.00297136.7-0.3417-0.07810.006505101520253033.544.555.566.577.58174.5Spline2xix()iiafxibicid0174.51.10570.0000-0.03031207.00.2885-0.27240.02542236.1-0.6599-0.04370.20363245.6-0.13660.5670-0.23054255.80.3061-0.1244-0.08935275.2-1.2633-0.66030.3144627.74.1Spline3xix()iiafxibicid027.74.10.74860-0.91021284.30.5028-0.81910.11632294.1-0.7865-0.47020.15673303.0functionp155q29clearallx1=[125678101317]';fx1=[3.03.73.94.25.76.67.16.74.5];x2=[17202324252727.7]';fx2=[4.57.06.15.65.85.24.1];x3=[27.7282930]';fx3=[4.14.34.13.0];c=csi(x1,fx1)n=size(c,2);nn=n-1;nii=11;m1=nn*nii;forj=1:nnforii=1:niix((j-1)*nii+ii)=x1(j)+(ii-1)*(x1(j+1)-x1(j))/nii;s((j-1)*nii+ii)=c(1,j)+c(2,j)*(x((j-1)*nii+ii)-x1(j))+...+c(3,j)*(x((j-1)*nii+ii)-x1(j))^2+c(4,j)*(x((j-1)*nii+ii)-x1(j))^3;endendc=csi(x2,fx2)n=size(c,2);nn=n-1;nii=11;m2=nn*nii;forj=1:nnforii=1:niix(m1+(j-1)*nii+ii)=x2(j)+(ii-1)*(x2(j+1)-x2(j))/nii;s(m1+(j-1)*nii+ii)=c(1,j)+c(2,j)*(x(m1+(j-1)*nii+ii)-x2(j))+...+c(3,j)*(x(m1+(j-1)*nii+ii)-x2(j))^2+c(4,j)*(x(m1+(j-1)*nii+ii)-x2(j))^3;endendc=csi(x3,fx3)n=size(c,2);nn=n-1;nii=11;m3=nn*nii;forj=1:nnforii=1:niix(m1+m2+(j-1)*nii+ii)=x3(j)+(ii-1)*(x3(j+1)-x3(j))/nii;s(m1+m2+(j-1)*nii+ii)=c(1,j)+c(2,j)*(x(m1+m2+(j-1)*nii+ii)-x3(j))+...+c(3,j)*(x(m1+m2+(j-1)*nii+ii)-x3(j))^2+c(4,j)*(x(m1+m2+(j-1)*nii+ii)-x3(j))^3;endendplot(x,s)functionc=csi(x,fx)n=size(x,1);h=zeros(n-1,1);alpha=zeros(n,1);z=alpha;l=z;mu=h;c=zeros(4,n);fori=1:n-1h(i)=x(i+1)-x(i);endfori=2:n-1alpha(i)=3*(fx(i+1)-fx(i))/h(i)-3*(fx(i)-fx(i-1))/h(i-1);endl(1)=1;mu(1)=0;z(1)=0;fori=2:n-1;l(i)=2*(x(i+1)-x(i-1))-h(i-1)*mu(i-1);mu(i)=h(i)/l(i);z(i)=(alpha(i)-h(i-1)*z(i-1))/l(i);endl(n)=1;z(n)=0;c(3,n)=0;forj=n-1:-1:1c(3,j)=z(j)-mu(j)*c(3,j+1);c(2,j)=(fx(j+1)-fx(j))/h(j)-h(j)*(c(3,j+1)+2*c(3,j))/3;c(4,j)=(c(3,j+1)-c(3,j))/(3*h(j));c(1,j)=fx(j);endEndofQuestion29onPage155SeenextpagePage163Q.4UsethedatainthefollowingtableandAlgorithm3.6toapproximatethes