Potatoes! Activity 1.6.3

Andy Long, Spring 2024

The Problem:

The Data:

t=Table[15*i,{i,0,6}]
temp={70,180.5, 251, 296, 324.5, 342.8, 354.5}
ListPlot[Transpose[{t,temp}]]

The First Derivative:

I create functions to compute forward and centered difference formulas (note: centered is just an average of the forward and backward methods). 

And note that backwards is just a shifted version of forward, as we’ve seen.

forwardDiff[x_,f_]:=(Most[f]-Rest[f])/(Most[x]-Rest[x])
centeredDiff[x_,f_]:=Module[{forward=forwardDiff[x,f]},
(Most[forward]+Rest[forward])/2
]

forward=forwardDiff[t,temp]
centered=centeredDiff[t,temp]

Use the best approximation we can at the ends (that’s forward at the left, and backward at the right):

dfdt=
Flatten[AppendTo[AppendTo[{First[forward]},centered],{Last[forward]}]];
TableForm[Transpose[{temp,dfdt}]]
ListPlot[Transpose[{t,dfdt}]]

The Second Derivative:

Same steps. (Do we believe that final plot?)

forward=forwardDiff[t,dfdt];
centered=centeredDiff[t,dfdt];
d2fdt2=
Flatten[AppendTo[AppendTo[{First[forward]},centered],{Last[forward]}]];
TableForm[Transpose[{temp,d2fdt2}]]
ListPlot[Transpose[{t,d2fdt2}]]