Assume there are discrete states the system can be in: . Let sampling the state over an indefinite time period, and be the energy in state . The system will have 2 contraints, the probabilities must add to 1, and the average energy should equal :
and
The second law of thermodynamics says that entropy will always increase. Over a long enough time period the entropy of the system,
should be maximized.
We want to find the probability distribution that maximizes , while following the 2 constraints.
Solve this system of equations with a Lagrange multiplier. First rewrite the 2 constraints like:
and
Then make the Lagrange equation
At the maximum the derivative with respect to any should be zero.
Set the derivative to zero.
Then Solve for .
Exponentiate both sides
Then split the exponent.
Now we have to solve for the 2 multipliers. Start with the first constraint:
And substitute .
The first term is independent of so it can be moved out of the sum.
Then divide both sides by the sum.
Now can be substituted.
Next solve to solve for use the second constraint:
Substitute in the equation for .
Look at the equation for the maximum entropy:
Then simplify
Split the logarithm
Cancel the logarithm and exponent
Split the summation.
The second term in the first summation is independent so it can be moved out.
Then from the first constraint the entire first summation is just equal to 1.
Move the out of the summation.
Then the summation is just equal to
Then is equal to the derivative which is ends up being the definition of temperature.
Substituting, the full equation becomes