Black body radiation energy density In the derivation of energy density of a black body, we calculate the number of modes by solving the EM wave equation. In this case we get that $$n=\sqrt{n_x^2+n_y^2+n_z^2}$$
Here we divide $n$ in three coordination in $n$-space, $n_x$,$n_y$,and $n_z$. These are all integers as we took those constants in solving the EM wave equation using the boundary condition that at $x=a$, $E=0$.
So as we know that at the wall of the cavity the electric field is zero, so there will be a node if I consider the EM wave as standing wave. From wall to wall an EM wave must have two nodes at the two ends of an EM standing wave, so the length of the EM wave will be an integer multiple of half the wavelength, or
$$L=n\lambda/2$$
Where $n$ is an integer.
So we can conclude that $n$, $n_x$, $n_y$, $n_z$ are all integers, but how can this be possible? If I say, for example, that $n_x=n_y=n_z=1$, then I have $n=\sqrt{3}$, which is not an integer.
So what is incorrect in the statement that all four constants $n$, $n_x$, $n_y$, and $n_z$ can't be integers simultaneously every time?
 A: You are generally solving (where $w = ct$ for some wave speed $c$), the equation $\partial_w^2 \phi = \nabla^2 \phi$ for a rectangular box with side-lengths $L_x, L_y, L_z.$ This is a linear partial differential equation, so we use our favorite trick, separation of variables. We assume that there are families of solutions $\phi_{ijk\ell} = W_i(w)~X_j(x)~Y_k(y)~Z_\ell(z)$ such that the general solution is given by a superposition, $$\phi(t, x, y, z) = \sum_{ijk\ell} c_{ijk\ell} ~\phi_{ijk\ell}(ct, x, y, z).$$Because the equation is linear it applies for each of the solutions individually and the equation becomes a set of ordinary one-variable derivatives:$$W''~X~Y~Z = W~X''~Y~Z + W~X~Y''~Z + W~X~Y~Z''.$$Dividing through by $WXYZ$ gives:$$W''/W = X''/X + Y''/Y + Z''/Z,$$and the argument is that since the rest of the expression is independent of $x$ therefore $X''/X = -k_x^2$ must be a constant independent of $x$ too.
We therefore solve each of these and find that $X_j(x)= \sin(\pi~j~x/L_x)$ etc. to be 0 on the walls at $x=0, x=L_x.$
By construction the resulting solution looks like $$\phi_{ijk\ell} = \sin(\omega_{jk\ell} t + \theta_i)~\sin(\pi~j~x/L_x) \sin(\pi~k~y/L_y) \sin(\pi~\ell~z/L_z)$$ which is zero on all of the boundaries. The frequency given for $\omega_{jk\ell}$ by the $W''/W = -k_x^2 - k_y^2 - k_z^2$ term, does not need to be similarly quantized because there is no time boundary condition that we're solving this over.
