# Finding heat capacity from an energy curve versus temperature

I plotted an energy curve from the following points:

{0.01,0.6004},{0.1,0.6354},{0.5,1.032},{1.1,1.8516},{1.5,2.4167},{2.0,3.1576}


What I want to do is compute the heat capacity form this curve by calculating the slope along the curve at various points and plotting the results. I tried using the following code:

heatcap[t]=(energy[t+.01]-energy[t])/.02;
Plot[heatcap[t],{t,0.2,1.99}].


All that I got from this was a grid and no points. I am really baffled by this and need some guidance.

Since you did not give an explicit explanation of you data list, I suppose they are in the form of (temperature, energy) with SI unit.

energyVsTemperature = {{0.01,0.6004}, {0.1,0.6354}, {0.5,1.032}, {1.1,1.8516}, {1.5, 2.4167}, {2.0, 3.1576}};
experimentData = ListPlot[energyVsTemperature, PlotStyle -> {Red, PointSize[.02]}];


Instead of your formula heatcap[t]=(energy[t+.01]-energy[t])/.02, I will use the derivative of an interpolation function for energyVsTemperature to calculate the heat capacity.

Firstly, an interpolation function for heat capacity, i.e. heatCap, is made with Interpolation[...]:

heatCap = Interpolation[energyVsTemperature];
interpolatedHeatCapPlot = Plot[heatCap[t], {t, 0.01, 1.99}, PlotStyle -> Blue]


Validate our interpolation function for heat capacity:

Show[{experimentData, interpolatedHeatCapPlot}, Frame -> True,
FrameLabel -> {"Temperature", "Energy"},
Epilog -> Inset[Column[{
LineLegend[{Blue}, {"Interpolated function"}],
PointLegend[{Directive[Red, PointSize[0.02]]}, {"Experiment data"}]}],
Scaled[{.8, .3}]]]


We can use Manipulate[...] to obtain the heat capacity at each Temperature:

Manipulate[Show[{experimentData, interpolatedHeatCapPlot, Graphics[{PointSize[.03], Point[{loc[[1]], heatCap[loc[[1]]]}]}]},
Frame -> True, FrameLabel -> {"Temperature", "Energy"}, PlotLabel ->"Current heat capacity = " <> ToString[D[heatCap[t], t] /. t -> loc[[1]]],
ImageSize -> {480, 320}, Epilog -> {Inset[Column[{
LineLegend[{Blue}, {"Interpolated function"}],
PointLegend[{Directive[Red, PointSize[0.02]]}, {"Experiment data"}]}],
Scaled[{.8, .3}]]}],
{{loc, {0.3, heatCap[0.3]}}, Locator, Appearance -> None}, AppearanceElements -> None]