# Leave Parts of Formula inactive in partial Differentiation

for thermodynamics, I would like to use a thermodynamic derivative $$\frac 1 T=\frac{\partial S}{\partial E}\Bigg \vert_V$$i.e. the derivative of the entropy S with respect to the energy E with the volume kept constant. In this context I tried to differentiate as follows (subsituting E to Z since E is protected)

    V[Z_]:=Z^6;
S[Z_]:=V[Z]^2-Z;

TemperatureDef=1/T==D[S,Z]


How do I differentiate S with respect to Z without V[Z] being evaluated (i.e. plugged in)?

• Please don't use underscores (a.k.a. Blank) in variable names: They have its own meaning in Mathematica (They are used to build patterns.) – Henrik Schumacher Aug 23 '18 at 13:27
• You can try something like this: ClearAll[V];S = V[Z]^2 - Z; 1/T == D[S, Z] – Henrik Schumacher Aug 23 '18 at 13:29
• The function Dt might also be useful – KraZug Aug 23 '18 at 13:49
• – Michael E2 Aug 25 '18 at 0:07

Why not make the dependence explicit:

S[V_, Z_] := V^2 - Z
V[Z_] := Z^6


Then:

Derivative[0, 1][S][V[Z], Z]


-1

See below for some discussion.

Block[{V},
SetAttributes[V, Constant];
S'[V]
]
(*  -1  *)


Note that if you change S =.. to S[Z_] :=.., you should change D[S,Z] to D[S[Z],Z], which is equivalent to S'[Z] above.

Perhaps one of these methods will get you started. First, though, you have to Clear your previous definitions. Set (=) does not set up equations but makes symbols represent the values of the right-hand side at the time of definition. Hence S=V^2-Z makes S equal Z^12 - Z, and the value for S contains no instance of V.

ClearAll[S, V, Z];


1. Setting temporarily the attribute Constant:

Block[{V},
SetAttributes[V, Constant];
D[V^2 - Z, Z]]
(*  -1  *)


2. Using the option Constants of Dt:

Dt[S]/Dt[Z] /.
First@Solve[
Dt[{S == V^2 - Z}, Constants -> {V}] /.
Verbatim[Dt][x_, ___] :> Dt[x], {Dt[S]}]
(*  -1  *)


Or this way seems a little cleaner:

InternalInheritedBlock[{Dt},
SetOptions[Dt, Constants -> {V}];
Dt[S]/Dt[Z] /. First@Solve[Dt[{S == V^2 - Z}], {Dt[S]}]
]
(*  -1  *)

• Ok, that works as long as V is indeed a constant defined by set (=). But how does it work if it is S[Z_],V[Z_] ? Do you know a way to set functions temporarily to a constant? – Uwe.Schneider Aug 24 '18 at 19:01
• @Uwe.Schneider That's not how the original question was set up, was it? – Michael E2 Aug 24 '18 at 22:03

A Little cludgy, but for temporary setting, try

V[Z_]=Z^6;
S[Z_]=V[Z]^2-Z;

Temperature_Def=1/T==D[(S[Z]),Z]/.D[V[Z]^2,Z]->0
(* 1/T==-1 )
`