# Lagrange multipliers in Maxwell-Boltzmann statistics

I'm following Wikipedia's derivation of Maxwell-Boltzmann statistics.

After applying Lagrange multipliers, we arrive at this expression for energy:

$$E={\frac {\ln W}{\beta }}-{\frac {N}{\beta }}-{\frac {\alpha N}{\beta }}}$$

with $$\alpha$$ and $$\beta$$ as the constants emerging from the constraints.

Next, it is explained that Boltzmann simply identified this as an expression of the fundamental thermodynamic relation:

$$E=TS-PV+\mu N}$$

and just set the constants $$\alpha$$ and $$\beta$$ equal to $$-\mu/kT$$ and $$1/kT$$ to set the expression so that they are equal.

I can understand that setting the constants in this way does make the expressions same, but why is it physically or mathematically justified? I've been taught the method of Lagrange and we always had to solve a system of equations to figure out the constants and then finally solve the maxima or minima. But here we are simply setting the constants so that we can arrive at a nice expression, but why is it ok to just set the constants this way and conclude that we have arrived at something that represents reality?

Here we are not choosing some constant. We are arriving at the values of $$\beta$$ and $$\alpha$$. In the first equations $$\ln(W)$$ and $$N$$ are the variables which are arbitrary. Substituting $$S=k \ln(W)$$ and $$PV=NkT$$ in the second equation gives $$Tk\ln W-kTN+\mu N=0$$
Comparing with first equation, since $$\ln W$$ and $$N$$ are arbitrary, gives the value $$\beta=\frac{1}{kT}$$ $$\alpha=\frac{-\mu}{kT}$$.