How does maximization of entropy imply minimization of energy? Consider the Wikipedia article "https://en.wikipedia.org/wiki/Principle_of_minimum_energy". It clearly says 


*

*For an isolated system with fixed energy, the entropy is maximized.

*For a closed system with fixed entropy, the energy is minimized.


The problem comes when they provide a mathematical explanation under the header  "Mathematical explanation" (in the same article). It first states that
$$\bigg(\dfrac{\partial S}{\partial X}\bigg)_U=0,~~\bigg(\dfrac{\partial^2 S}{\partial X^2}\bigg)_U<0,$$
 at equilibrium for an isolated system with fixed internal energy. Then the article uses some algebra to connect these terms to 
$$-\dfrac{1}{T}\bigg(\dfrac{\partial U}{\partial X}\bigg)_S~~\&~~-\dfrac{1}{T}\bigg(\dfrac{\partial^2 U}{\partial X^2}\bigg)_S~~\text{respectively}.$$ This is then used to claim the minimization of energy.
My confusion is that the entropy maximization requires internal energy constant (point 1 above). Thus 
$$\dfrac{\partial U}{\partial X}=\dfrac{\partial U^2}{\partial X^2}=0.$$
The first equality is okay, but for the minimization of the internal energy, we require that the second one be positive and not $0$.
I was not aware of a connection, mathematical in nature, between the minimization of internal energy and the maximization of entropy, till I came across this Wikipedia document. This then leads to all of this confusion. I don't see where I am going wrong. Also, this is the proof given in the thermodynamics books by R.H. Swendsen. Any help is highly appreciated.
 A: I will attempt an answer to this, although I'm not 100% sure I understand the question, I see that there is some confusion with respect to the derivation of the minimum energy principle, and I think I know where the confusion comes from.
What the article shows is that if the function $S$ has an extrema at a point $(U_0, X_0)$, for which it takes the value $S_0 = S(U_0, X_0)$ then the function $U$ has an extrema at the point $(S_0, X_0)$, for which it takes the value $U_0$. This extrema is a maximum for the function $S$ but a minimum for the function $U$ it is a minimum.
I think your confusion is related with the fact that writing down $$\frac{\partial S}{\partial X} \bigg|_U$$ seems to imply somehow that now the other function, $U$ is a constant, and when you take its derivative it should vanish, but this is not the case, using this notation for the derivative only means that $S$ is being considered as a function of $X$ and $U$, and not other variables. A different way to write this would be:
$$\frac{\partial S_{U,X}}{\partial X}$$ where the subindices just indicate as a function of which variables you are considering your function to depend on. Using this notation then, the derivation reads something like this, for the first derivative:
$$\frac{\partial S_{U,X}}{\partial X} = -\frac{\partial S_{U,X}}{\partial U} \frac{\partial U_{S, X}}{\partial X} = - T \frac{\partial U_{S, X}}{\partial X} $$ Where I've used the cyclic chain rule. From this equality you can see that the gradients of both functions are related, so that if one has a critical point then the other one does too, and at no point I have considered $U$ to be just a constant.
Edit after comment:
It seems that what is unclear is that the derivative $$\frac{\partial S_{U, X}}{\partial U}$$ is not zero for a fixed value of energy. Maybe this way of thinking about it would help:
If you have a function $F(x,y) = yx + x^2$ for example, and you take the derivative with respect to x then the result is $$\frac{\partial F_{x,y}}{\partial x}(x, y) = y + 2x$$. Lets say now that we want to study this function for a fixed value of x, namely $x_0$, then our function will be $$F(x_0, y) = yx_0 + x^2_0$$ and our derivative will be  $$\frac{\partial F_{x,y}}{\partial x}(x_0, y) = y + 2x_0$$ which is not necessarily equal to zero. 
A similar thing happens when you want to study the function $S(U_0, X)$ and its derivative with respect to $U$; $$\frac{\partial S_{U,X}}{\partial U}(U_0, X)$$ is not necessarily equal to zero. 
