Gibbs entropy maximization confusion with Grand Canonical Ensemble I'm trying to review some statistical mechanics from the following link
In doing so on the topic of variational theory and maximization with Lagrange multipliers, the author states that given a function:
$$
h(x_i) = f(x_i) - \lambda g(x_i),
$$
then to extremize we require the condition:
$$
\frac{\partial h}{\partial x_i} = 0.
$$
Though this is phrased a little differently than I am used to, the conclusion is the same and so I am okay with it.
However, later on the author solves this example with the case of a Grand Canonical Ensemble (GCE). In my own understanding, the GCE is described by the number of particles, and the energy. I arrived at the same constrain equations as the author however, based on my understanding the the parameteres of the same are described by $(E,N)$, I would have expected that there should have been two equations set to equal zero:
$$
\frac{\partial}{\partial E_n} \left[S - \lambda_E \sum P(E,N) E - \lambda_N \sum P(E,N) N - \lambda_1 \sum P(E,N) \right] = 0,
$$
and
$$
\frac{\partial}{\partial N_n} \left[S - \lambda_E \sum P(E,N) E - \lambda_N \sum P(E,N) N - \lambda_1 \sum P(E,N) \right] = 0.
$$
I was able to find another text that arrives at the same solutions for the probability function, with different variable substitutions (in terms of $\mu$ and $\beta$) so I presume that this procedure is the correct one. I suspect my confusion is related to idea of: what is a function of what. Which has been a bane of my existence through all of my courses on thermodynamics and statistical mechanics.
Any explanation would be greatly appreciated! :)
 A: There are three constraints in the grand canonical ensemble:
$$ \sum_{n,j} a(n,j) = \mathcal{N} $$
$$ \sum_{n,j} a(n,j) E_j= \mathcal{N} \bar{E} $$
$$ \sum_{n,j} a(n,j) N_n= \mathcal{N} \bar{N} $$
$a(n,j)$ represents the number of samples with $N_n$ particles and energy $E_j$ in the giant canonical ensemble. $\mathcal{N}$ is the total number of samples. $w=\dfrac{\mathcal{N}!}{\Pi_{n,j}a(n,j)!}$ is the total number of microstates.
When we use the Lagrangian method, the function that needs to be constructed is:
$$f({a(n,j),\alpha,\beta, \gamma} = \ln w -\alpha ( \sum_{n,j} a(n,j) - \mathcal{N} )-\beta( \sum_{n,j} a(n,j) E_j - \mathcal{N} \bar{E} ) - \gamma (\sum_{n,j} a(n,j) N_n-\mathcal{N} \bar{N}) $$
The independent variables of the function f are only $ a(n,j),\alpha,\beta, \gamma $. 
$ \bar{E}, \bar{N}$ is the expectation of the number of particles and energy given in advance, $E_j, N_n$ is our artificial standard, such as $N_n$ must be $0,1,2,3...$ so they are constants rather than self-energy, and there is no need to take partial derivatives for them.
