Grayson Rodriguez - 3.3 - Hermite Interpolation

hermiteInterpolation[xList_,fList_,dfList_]:=Module[{n,z,q,q1,q2,empty},

n=Length[xList];
z=N/@Riffle[xList,xList];
q1=N/@Riffle[fList,fList];
q2=N/@dfList;
empty=Transpose[Table["",{i,1,2*n},{j,1,2*n}]];
q=ReplacePart[empty,1->q1];

Do[q[[2,2i]]=q2[[i]],{i,1,n}];
Do[q[[2,2i+1]]=(q[[1,2i+1]]-q[[1,2i]])/(z[[2i+1]]-z[[2i]]),{i,1,n-1}];
Do[If[j≥i,q[[i,j]]=(q[[i-1,j]]-q[[i-1,j-1]])/(z[[j]]-z[[j-i+1]])],{i,3,2n},{j,3,2n}];

Print[TableForm[Transpose[Prepend[q,z]],TableHeadings->{None,Prepend[Prepend[Range[2n-1],"f(z)"],"z"]}]];
Print["The Hermite coefficients:"];
Print[TableForm[Table[q[[i,i]],{i,1,2*n}],TableHeadings->{Range[0,2n-1],{"Coefficients"}}]];

]

1

b

hermiteInterpolation[{.8,1},{.22363362,.65809197},{2.1691753,2.0466965}]

So, (Subscript[H, 3])(x)=0.22363362`+2.1691753`(x-0.8)+0.015582250000001355`(((x-0.8))^2)-3.2177925000000176`(((x-0.8))^2)(x-1)

c

hermiteInterpolation[{-.5,-.25,0},{-.02475,.3349375,1.101},{.751,2.189,4.002}]

So, (Subscript[H, 5])(x)=-0.02475`+0.751`(x+0.5)+2.751`(((x+0.5))^2)+(((x+0.5))^2)(x+0.25)-7.105427357601002`*^-15 (((x+0.5))^2)(((x+0.25))^2)+2.1316282072803006`*^-14 (((x+0.5))^2)(((x+0.25))^2)x
The last two terms are approximately zero.

3

b

h[x_]:=0.22363362+2.1691753(x-0.8)+0.01558225(((x-0.8))^2)-3.2177925(((x-0.8))^2)(x-1)
f[x_]:=Sin[(E^x)-2]
Print[Grid[{{"H(0.9) =",h[0.9]},{"f(0.9) =",f[0.9]},{"Abs. error =",Abs[f[0.9]-h[0.9]]}},Frame->True,Alignment->Left]];

c

h[x_]:=-0.02475+0.751(x+0.5)+2.751(((x+0.5))^2)+(((x+0.5))^2)(x+0.25)-7.105427357601002*^-15 (((x+0.5))^2)(((x+0.25))^2)+2.1316282072803006*^-14 (((x+0.5))^2)(((x+0.25))^2)x
f[x_]:=(x^3)+4.001(x^2)+4.002x+1.101
Print[Grid[{{"H(-1/3) =",h[N[-1/3]]},{"f(-1/3) =",f[N[-1/3]]},{"Abs. error =",Abs[f[N[-1/3]]-h[N[-1/3]]]}},Frame->True,Alignment->Left]];

6

f[x_]:=3x (E^x)-(E^(2x))

hermiteInterpolation[{1,1.05},{f[1],f[1.05]},{f'[1],f'[1.05]}]

h[x_]:=0.7657893864+1.531578773(x-1)-2.774886304(((x-1))^2)-4.750236619(((x-1))^2)(x-1.05)
Print[Grid[{{"(Subscript[H, 3])(1.03) =",h[1.03]},{"f (1.03) =",f[1.03]},{"Abs. error =",Abs[f[1.03]-h[1.03]]}},Frame->True,Alignment->Left]];

hermiteInterpolation[{1,1.05,1.07},{f[1],f[1.05],f[1.07]},{f'[1],f'[1.05],f'[1.07]}]

h[x_]:=0.7657893864+1.531578773(x-1)-2.774886304(((x-1))^2)-4.750236619(((x-1))^2)(x-1.05)-3.504301565(((x-1))^2)(((x-1.05))^2)-1.707805478(((x-1))^2)(((x-1.05))^2)(x-1.07)
Print[Grid[{{"(Subscript[H, 5])(1.03) =",h[1.03]},{"f (1.03) =",f[1.03]},{"Abs. error =",Abs[f[1.03]-h[1.03]]}},Frame->True,Alignment->Left]];

10

a

hermiteInterpolation[{0,3,5,8,13},{0,225,383,623,993},{75,77,80,74,72}]

h[x_]:=75x+0.2222222222(x^2)(x-3)-0.03111111111(x^2)(((x-3))^2)-0.006444444444(x^2)(((x-3))^2)(x-5)+0.002263888889(x^2)(((x-3))^2)(((x-5))^2)-0.0009131944444(x^2)(((x-3))^2)(((x-5))^2)(x-8)+0.0001305267916(x^2)(((x-3))^2)(((x-5))^2)(((x-8))^2)-0.00002022363197(x^2)(((x-3))^2)(((x-5))^2)(((x-8))^2)(x-13)

h[10]

b

speed[x_]=(3600/5280)*h'[x];

Plot[{speed[x],55},{x,0,13},PlotRange->{30,90}]

Solve[speed[x]==55,x]

Yes! The first time is an infinitesimal amount after  t=5.648802543.

c

Solve[h''[x]==0,x]

speed[12.37184029]

The predicated maximum speed is 81.42091294 (mi/h).