Entropy as a function of temperature: is temperature well defined? Considering volume and particle number constant, the internal energy $U$ is a function of the entropy: $U=U(S)$. The temperature is then defined as $T=dU(S)/dS$. From here, the temperature is a function of the entropy: $T=T(S)$. 
One can now define the free energy $F=F(T)$ as
$$F(T) = U-TS = U(S(T)) - TS(T)$$
For this, however, $T(S)$ has to be invertable. My question is, what happens if $U(S)$ is some wavy function such that its derivative is the same at many distinct $S$ values? In other words, what happens if $T^*=T(S^*)$ has multiple solutions for $S^*$? Is it possible not to have a well defined temperature at equilibrium?
My wild guess is that this shouldn't happen in the thermodynamic limit, but can't see this. Also, small, even single particle systems have well defined temperature so is there some constraint on the shape of $U(S)$ I'm missing here?
 A: Function $T(S)=(\partial U/\partial S)_V$ does not have to be strictly increasing with $S$. For example, when heat is added to a mix of ice and water at 0 degrees Celsius, entropy increases but temperature stays the same until all ice is melted. So it is not, in general, possible to express entropy as function of $T,V,N$.
Free (Helmholtz) energy is usually defined as
$$
F(T,V,N) = U - TS
$$
but in general neither $U$ nor $S$ can be expressed as functions of $T,V,N$.
A: Your question requires an answer on three different levels:


*

*mathematical;

*pure thermodynamics;

*statistical mechanics.


1. mathematics 
The definition of the Helmholtz free energy you refer to is nothing but the Legendre transform of the fundamental equation $U(S,V,N)$ with respect to its first variable $S$ in term of the conjugate variable $T=\left( \frac{ \partial{U}}{\partial{S}} \right)_{V,N}$. The original Legendre transform would be easily done by requiring $U$ to be a twice differentiable function of $S$ with a positively defined hessian matrix. However, such a request is too strong for real thermodynamic systems. It is well known that a useful extension of the Legendre transform is the so-called Legendre-Fenchel transform (LF) (or convex-conjugate).
In the case of thermodynamics, the definition of LF transform is slightly different from the most common mathematical definition. In the case of the Helmholtz free energy, it would be written as
$$
F(T,V,N) = \inf_{S}( U(S,V,N) - TS )
$$
Such a definition reduces to the usual Legendre transform in the part of the domain of $U(S,V,N)$ where the function is strictly convex (and twice differentiable with respect to $S$). Where the function is convex but not strictly convex (i.e. what mathematicians call an affine function, i.e. a linear function), the LF transform maps the entire affine interval into a single point where left and right derivatives differ.
Since fundamental equations must be convex (o cancave) but not strictly convex (or strictly concave), it turns out that the LF transform is the proper mathematical tool for a change of variable $S \leftrightarrow T$.
2. Pure thermodynamics
Affine regions of $U(S,V,N)$ are to be expected, due to the phenomenon of phase coexistence. In such regions, the thermodynamic potential must be a linear function of its extensive variables since it corresponds to an equilibrium condition of an inhomogeneous system made by more coexisting phases. At coexistence, $T(S,V,N)$ is a constant as a function of $S$. But this is physically consistent with the presence of a latent heat at the first order phase transition.
3. Statistical mechanics 
Statistial mechanics is deemed to give access to Thermodynamics, by starting with a model for the Hamiltonian of the system. However, such a program in general requires the so-called thermodynamic limit (TL). TL is required for different reasons. Summarizing, these are:


*

*only TL can introduce the non-analiticity required to recover phase transitions;

*only at TL (if it exists) it is possible to recover the extensiveness

*only at TL (if it exists) it is possible to recover the convexity properties.


Without TL many properties, which are considered typical for thermodynamic systems, would not be valid. On the other hand, working with a finite number of degrees of freedom, although unavoidable from the numerical point of view, in general introduces non-convex (unphysical) regions. Therefore, TL is required, but at TL the $T(S,V,N)$ is not invertible for $S$ in the whole coexistence region. Nevertheless, LF transform can cope without problem with the situation.
