# Why are we able to switch variables so easily in thermodynamics?

My understanding of the Legendre transform is as the following:

If we have a function $f=f(x)$ with $df=pdx$, then we can define the legendre transform $f^*$ of $f$ as:$$f^*(p)=px-f(x).$$ $f^*$ is initially a function of $x$ but we can write it in terms of $p$ instead if $p$ was a monotonous function of $x$.

However, when studying thermodynamic potentials, I found out that we switch variables without making any deal of the monotony part and without being afraid of losing any information, so why is it the case?

The missing piece in the puzzle is the convexity of (some of) the thermodynamic variables as @ACuriousMind has pointed out. The convexity of, say, the entropy function $S$ is usually demonstrated from the entropy maximum principle along the lines as in Callen, chapter 8. The underlying idea is that the entropy is maximum in all displacements that are externally isolated. If only internal energy gets moved around, that is $$S(U + \Delta U, V,N) + S(U - \Delta U, V,N) \le 2S(U, V, N)$$ from which it follows upon taking the limit $\Delta U \to 0$ that $$\left( \frac{\partial ^2 S}{\partial U^2 }\right)_{V,N} \le 0$$ expressing the convexity of the entropy function with respect to $U$. Similar consideration for volume exchange gets you $S(U, V+ \Delta V, N) + S(U , V- \Delta V,N) \le 2S(U, V, N)$ and $\left( \frac{\partial ^2 S}{\partial V^2 }\right)_{U,N} \le 0$, etc. So the $S(U,V,N)$ is convex, that is the $S$ lies below its tangent planes everywhere.