Understanding "natural variables" of the thermodynamic potentials using the example of the ideal gas

I'll answer your questions one by one.

  1. About what makes $U(S,V,N)$ natural:

Keep in mind that thermodynamics started out as an experimental science, with people looking to use it for practical purposes (such as Carnot, etc.). Now as energy has always had center stage in physics, since it is conserved in many systems, so it made for a good starting point. One observation people made about energy is that it $\textbf{scales with the system}$. What that means is that by increasing the size of the system (all its parameters), the energy also increased in proportion. This means that when looking for an equation for the energy, we need to look for parameters which also scale with the system, or mathematically speaking, we need an equation that is $\textbf{first order homogeneous}$, i.e. $$U(\lambda X_1, \lambda X_2 ...) = \lambda U(X_1, X_2...)$$ Where $\lambda \in \mathbb{R}$ and $X_1,X_2...$ are the parameters. The parameters for which the above is true are known as $\textbf{extensive parameters}$. Intuitively, these are the volume, $V$ and the number of particles, $N$. Less intuitively, the entropy, $S$ is also extensive. There are other extensive parameters which are used to calculate $U$, such as magnetic moment. But for most simple systems, $S,V,N$ are enough.

  1. About deriving $U(T,p,N)$

Given $U(S,V,N)$, you can find $T$ and $-p$ as taking the partial derivative of $U$ with respect to $S$ and $V$ respectively. Note that $T$ and $-p$ are $\textbf{intensive parameters}$, wherein they are NOT homogeneous first order. The equation would look something like: $$T(\lambda X_1, \lambda X_2 ...) = T(X_1, X_2...)$$ Now since we have partial derivatives, you could write down functions $U$ as a function of $T$ and $p$, but in doing so, you would be losing information. Suppose you gave your new function $U(T,p,N)$ to a friend and he wanted to find $U(S,V,N)$, he would have to conduct 2 integrals, which would leave him wanting 2 constants of integration to nail down the function. So you see you can 'derive' $U(S,V,N)$ from $U(T,p,N)$ only upto a constant. This is why the Legendre transformations are helpful. They are a way to change coordinates without losing information.

$\textbf{When I say he has to conduct 2 integrals, I mean the following:}$

Suppose you expressed $U$ as a function of $T,p,N$, and using the following relations: $$T=\left(\frac{\partial U}{\partial S}\right)_{V,N} , -p=\left(\frac{\partial U}{\partial V}\right)_{S,N} , $$ Then, you'll have the following type of equation $$U=f\left(\frac{\partial U}{\partial S},\frac{\partial U}{\partial V},N\right)$$ Which is a partial differential equation ($f$ is some function of the variables). In the best case scenario that this is separable, 2 integrals would have to be conducted and hence 2 integration constants would be needed to obtain the exact function $U(S,V,N)$.

$\textbf{About Ideal Gases:}$ There are many ways to work out fundamental relations for ideal gases. The one you referenced in your question actually comes from Statistical Mechanics after considering phase space volumes. Thermodynamics alone is incomplete and requires many manipulations to get the results we want. In most cases, we only have expressions for $T$ and/or $p$, known as $\textbf{equations of state}$. What is really important to understand is the difference between the $\textbf{energy representation}$ and $\textbf{entropy representation}$. When the fundamental relation takes the form $U(S,V,N)$, we are working in the energy representation. If it is of the form $S(U,V,N)$, we have the entropy representation. Now the equation of state (relating to T) for the entropy representation is $$\frac{1}{T}=\left(\frac{\partial S}{\partial U}\right)_{V,N}$$ In the above it is clear that the right hand side must be a function of $U,V,N$. So the equipartition equation you wrote down is not a fundamental equation, but an equation of state in the entropy representation!

The first law of thermodynamics states that we can write the change in internal energy as the heat applied plus the work done on the system $$ \mathrm{d}U = \delta Q + \delta W\,. $$

In order to make some use of this expression we need to find some expression for $\delta Q$ and $\delta W$. In general this is difficult, not least because work and heat are path dependent quantities. In the special case of a reversible path, however we make some progress. In particular the reversible work $\mathrm{d} W_\mathrm{rev} = -p \mathrm{d}V + \mu \mathrm{d}N$ and from the definition of entropy we have $\mathrm{d} Q_\mathrm{rev} = T\mathrm{d}S$. Pluggin gthis into the fist law gives us $$ \mathrm{d}U = T\mathrm{d}S - p\mathrm{d}V+\mu \mathrm{d}N\,. $$ Moreover because all the variables in this expression are functions of state, this expression must be path independent, and so holds on all paths and not just reversible ones.

Notice that this differential is exceptionally simple. It only contains the thermodynamic variables or their differentials, not complicated functions of them. It also allows us to write expressions like $p = -\left(\frac{\partial U}{\partial V}\right)_S$, giving us an easy way to calculate the pressure or temperature.

This is what is meant when we say that $U$ is naturally a function of $S$, $V$ and $N$. If $U=U(S,V,N)$ it has an exceptionally simple differential that allows us to relate the different thermodynamic variables. We could write $U$ as a function of say $T$ and $P$ $$ \mathrm{d}U = \left(\frac{\mathrm{d}U}{\mathrm{d} T}\right)_p\mathrm{d} T + \left(\frac{\mathrm{d}U}{\mathrm{d} P}\right)_T\mathrm{p} $$ but $\left(\frac{\mathrm{d}U}{\mathrm{d} T}\right)_p$ would generally be some complicated function of the different thermodynamic variables.

Notice as well that this derivation used only generally properties of any thermodynamic system, it did not depend on the exact details of the system being considered. If we tied to define "natural" variables based on the explicit form of $U$ as a function of the variables, rather than using the differentials we would not find much general behaviour.

Similarly when we look at quantities such as the enthalpy or the Gibbs free energy we can derive similar simple differentials, allowing us to relate the other thermodynamic variables through the derivatives of the potentials.

There are already some good answers here, but I just wanted to add an approach to thinking about natural variables using the notion of Availability- which I think makes the whole thing more intuitive.

Derivation of the Availability as extractible work

We start from the entropy of a system, and the principle that entropy must always increase:

$$ dS \ge 0 $$

For an isolated system this expression is useful enough by itself, and we can just rearrange the first law to get:

$$ dS = \frac{dU + pdV - \mu dN}{T} $$

The equation of state can then be subbed into this equation, which can then be solved when the various constraints are applied.

When there is a system in contact with a reservoir, which is often how systems are thought of in thermodynamics, it is much more convenient to consider the change of entropy of the system and the reservoir simultaneously. To do this we can define the Availability of a system, using the second law, that entropy must always increase as stated above, as:

$$ dS_{tot} = dS_{sys} + dS_{reservoir} \ge 0 $$ $$ dS_{tot} = dS_{sys} + \frac{dU_{R} + p_{R}dV_{R} - \mu_{R} dN_{R}}{T_{R}} \ge 0 $$ $$ dS_{tot} = \frac{dS_{sys}T_{R} + dU_{R} + p_{R}dV_{R} - \mu_{R} dN_{R}}{T_{R}} \ge 0 $$

Using the fact that the system and reservoir are isolated from any outside systems, we have $ dV_{R} = - dV_{sys}$, $ dN_{R} = - dN_{sys}$ and $ dU_{R} = - dU_{sys}$. Subbing these in then simplifies the above expression to:

$$ dS_{tot} = \frac{dS_{sys}T_{R} - dU_{sys} - p_{R}dV_{sys} - \mu_{R} dN_{sys}}{T_{R}} \ge 0 $$

Now, dropping the subscript for the 'system' variables, the availability can be written as:

$$ dA = - T_{R}dS_{tot} = dU + p_{R}dV + \mu_{R} dN - T_{R}{dS} $$ $$ dA = (T -T_{R})dS - (p -p_{R})dV + (\mu -\mu_{R})dN $$

Where all the changes on the right hand side are with respect to the system variables.

The second law still applies to the availability, but in this new form it is written as:

$$ dA \le 0 $$

Now all this might seem superfluous to an explanation of the natural variables so far, but if we consider what the availability actually means then we can distill the intuition behind this reconstruction of the entropy.

Consider the amount of work which can be extracted from a system and reservoir ensemble. The amount of extractable work is clearly just the sum of internal energy in the system and reservoir:

$$ dW_{extractable} = -dU - dU_{R} $$

i.e. an amount of work done by the ensemble must be equal to the change in internal energy in the system and the reservoir- just conservation of energy. Now if we sub in the availability expression derived above we have:

$$ dW_{extractable} = p_{R}dV + \mu_{R} dN - T_{R}{dS} - dA - dU_{R} $$

Subbing in $ dV_{R} = - dV$, $ dN_{R} = - dN$, and the definition of dU from the first law, and rearranging gives:

$$ dW_{extractable} = -dA - T_{R}d(S + S_{R}) $$

In the reversible case the second term on the right handside is equal to zero, and so we have:

$$ - dA = dW_{extractable, max} $$

The availability gives the maximum amount of extractable work from a system.

Connection to Natural Variables

The amount of extractable work is of primary importance in many situations, though it often not explicitly stated in terms of the Availability. This is because historically, thinking about the change in free energy of an experimental system is much more convenient, e.g. Gibbs Free Energy is often used in chemistry, and the Hemholtz Free Energy in Physics. When these terms are introduced to students they are often just defined without reference to their derivations- at least in my experience of school and university Physics and Chemistry. But what is the difference between all these different uses of the term 'Free Energy'?

Essentially, these terms, as well as the Enthalpy and Grand Potential all express the same thing as the Availability, i.e. the amount of extractible work, but with respect to different constraints on the system. And these constraints are what define the natural variables of a state variable. Or more precisely, the natural variables will define the magnitude of a state variable, while the non-natural variables will define the magnitude of a change in the state variable.

E.g. for the Hemholtz free energy we can consider the amount of extractable work at constant T, V and N:

$$ dA = (dU + p_{R}dV + \mu_{R} dN - T_{R}{dS})_{const T, V, N} $$ $$ dA = d(U -TS) $$ $$ A_{const T, V, N} = F = U - TS $$

Where the constant terms are dropped between the first and second line. Thus we have $ F(T, V, N) = U - TS $ and $ dF = -SdT - pdV + \mu dN $

Similarly for the Gibbs free energy, which is the extractable work at constant T, p, N:

$$ dA = (dU + p_{R}dV + \mu_{R} dN - T_{R}{dS})_{const T, p, N} $$ $$ dA = d(U -TS +pV) $$ $$ A_{const T, p, N} = G = U - TS + pV $$

Which gives us $ dG(T, p, N) = \mu dN - SdT + Vdp $.

Finally, the internal energy is the amount of extractable work at constant V, N and S:

$$ dA = (dU + p_{R}dV + \mu_{R} dN - T_{R}{dS})_{const V, S, N} $$ $$ dA = d(U) $$ $$ A_{const V, S, N} = U $$

Which gives us $ dU = TdS -pdV +\mu dN $, which comes from the first law.