Exact differentials and state functions

For any function of multiple variables, say, $f(x, y, z, \ldots)$ you can always write the following:

$df = \big( \frac{\partial f}{\partial x} \big)_{y, z, \ldots} dx + \big( \frac{\partial f}{\partial y} \big)_{x, z, \ldots} dy + \big( \frac{\partial f}{\partial z} \big)_{x, y, \ldots} dz + \ldots$

In fact, the constancy of the other variables is implicit in the partial differential notation ($\partial/\partial x$) but it is customary to write the variables that are constant under the derivative when discussing thermodynamics, just to keep track of what other variables we were considering in that particular case.

The really confusing thing when discussing thermodynamics is the fact that your variables ($P, V, T$) are not independent. For instance, when considering $S$, the entropy, there are three variables, but they are also constrained by an additional equation, which is the equilibrium condition for the gas, which happens to be $PV = NkT$ for an ideal gas. So, you can pick any two to be independent variables, but the third will be dictated by the equilibrium condition.

Mathematically, of course, you can say $S = S(P, V, T)$. Let us see what happens then:

$dS = \big(\frac{\partial S}{\partial T} \big)_{P, V} dT + \cdots$

I just wrote the first term. It says, derivative of $S$ with respect to $T$, keep $P$ and $V$ constant. The question is, how can you change $T$ in the first place when keeping $P$ and $V$ constant? You can not, because the gas is (supposed to be) in equilibrium. So, what keeps you from doing this is the fact of the existence of the additional equation, hence you can not pick all three as independent variables. It's not the math, it's the physics.

If any quantity $X$ is a state function of a set of variables, then its differential will be an exact differential. Looks like a circular definition; so let me try to elaborate:

Think about this: You know that a friend just traveled from New York City to Boston, and now he is in Boston. Can you know the amount of gas he spent? The answer is no. The amount of gas he spent depends not only where he is now (well, that dependence is indirect, it sort of gives a minimum) but also what route he took and how aggressive he drove, how much traffic there was, air pressure, and whatnot. So if you call the amount of gas $G$, $G$ can not be known by looking at where he is right now (without investigating history) it is not a state variable. Therefore, $dG$ is not an exact differential.

But what about his distance to New York City? You know he is in Boston, and that is all you need to know. By just looking at his final state, you can tell what the distance is (I can not because I am too lazy to look at a map). So, his distance-to-New-York-City function $D$ is a state variable. Therefore $dD$ is an exact differential. It really does not matter how he traveled there; even if he teleported by magic, we still know $D$.

Now the third part. Darn thermodynamics, everything jumps around.

Let us say we picked $V$ and $T$ as our two independent variables. Which we can.

Then, we can say $S = S(V, T)$ and also $P = P(V, T)$. Now $P$ is not an independent variable, but once you know $V$ and $T$, it is known. So, since there is an equation $PV = NkT$, if you know what $V$ and $T$ are (your state variables - the independent ones - which you had a choice in picking) you do know what $P$ is, without having to know about the history of the gas.

This is not the answer to your question, of course. Here comes additional complication.

Look at the case more broadly. What you know is the existence of two relations among four variables $P, V, T, S$:

$F(P, V, T) = 0$ (this is the equilibrium condition)

$G(S, P, V, T) = 0$ (This is relation of $S$)

Just to be clear, in the ideal gas case, these two equations are:

$PV = NkT$ (which makes $F(P, V, T) = PV - NkT$ )

and

$S = Nk \ln \frac{VT^{c_v}}{N \Phi}$ ($c_v$ is the specific heat of the gas at constant volume, and $\Phi$ is a gas-dependent constant. This is as far as you can deduce using thermodynamics of an ideal gas only.)

For a non-ideal gas, the equations deviate from these forms, but a gas in equilibrium always has a state equation like $PV = NkT$, and there is always a "proper" expression for $S$.

Since I have two equations and four "unknown"s, it means I can choose any two of them as independent variables, and the other two will be specified by the equations.

So yeah... Now I exercise my freedom, and pick $S$ and $T$ as my independent variables. This makes $P = P(S, T)$ and also $V = V(S, T)$. And, since they are specified exactly by my state variables $V$ and $T$, $dP$ and $dV$ are exact differentials.

What are not exact differentials then? The work done by a system is not an exact differential. You can increase the temperature of a gas by compressing it, or by giving it heat. By looking at the final volume and temperature, I can not possibly say by which way the internal energy arrived. So, work $W$ and heat exchanged $Q$ are not state variables. It does not even make sense to talk about what the "heat" or "work" of a system is, precisely because they are not state variables. You can talk about work done in a process, or heat exchanged in a process since they are process-dependent.

Final re-iteration: If a value of a variable depends on the end points only, and not the path taken, then it is a state variable. If it does depend on the path, then it is not a state variable.

Thermodynamics is difficult like this, because (as Feynman has said) we can not decide once and for all what our independent variables are. This is not because physicists are evil, but because every problem requires a different approach, and we use whatever is more useful for that case.