I started working on it before JPi had answered, so I will post my solution anyways.
LuaTeX is ideal for this. For example, here is solution using ConTeXt (It should be easy to translate it to LaTeX).
\startluacode
userdata = userdata or {}
userdata.variables =
{
m = 10,
Cp = 30,
T1 = 15,
T2 = 20,
}
variables = userdata.variables
variables.DeltaT = variables.T2 - variables.T1
variables.Q = variables.m*variables.Cp*variables.DeltaT
local function showRow(a,b,c)
context("\\NC %s \\NC %s \\NC %s \\NC \\NR", a, b, c)
end
local function singleRow(a)
context("\\NC[nc=3, align=middle] %s \\NC \\NR", a)
end
local format = string.format
userdata.ShowVariables = function()
context.startTABLE{setups="table:variables"}
showRow("Parameter Value", "Units", "Description")
showRow("$m$", format("\\unit{%s KiloGram}", variables.m), "Mass")
showRow("$Cp$", format("\\unit{%s KiloJoule/Celsius KiloGram}", variables.Cp), "Heat Capacity")
showRow("$T_1$", format("\\unit{%s Celsius}", variables.T1), "Initial Temperature")
showRow("$T_2$", format("\\unit{%s Celsius}", variables.T2), "Final Temperature")
singleRow(format("$ΔT = T_2 - T_1 = %s - %s = %s~[\\unit{Celsius}]$", variables.T2, variables.T1, variables.DeltaT))
showRow("$ΔT$", format("\\unit{%s Celsius}", variables.DeltaT), "Temperature Difference")
singleRow(format("$Q = m × Cp × ΔT = %s × %s × %s = %s~[\\unit{KiloJoule}]$", variables.m, variables.Cp, variables.DeltaT, variables.Q))
showRow("$Q$", format("\\unit{%s KiloJoule}", variables.Q), "Heat")
context.stopTABLE()
end
\stopluacode
\startsetups table:variables
\setupTABLE[frame=off, offset=0.25em]
\setupTABLE[column][3][width=12em]
% Width needed, otherwise column span doesn't work
\stopsetups
\define\ShowVariables{\ctxlua{userdata.ShowVariables()}}
\starttext
\ShowVariables
\stoptext
which gives

I used a separate namespace userdata to avoid conflict with existing variable names.
tikz/pgfplotspackage for such calculations. You may also like to look at thespreadtabpackage, it is probably already installed in your TeX distribution. – Malipivo Apr 05 '14 at 05:54spreadtabshould be able to handle this, see http://tex.stackexchange.com/questions/70860/can-latex-perform-calculation-like-excel-formula-table/70865 – cgnieder Apr 05 '14 at 07:36spreadtabpackage it seems to be able to do the calculations I want but not display the formula used to generate the numbers too. Perhaps I would need to create a macro to extend spreadtab? – tranquillity Apr 05 '14 at 23:14