# Electromagnetic field in a cavity

I'm reading the book "The Quantum Theory of Light", by Rodney Loudon, and I came across the following passage describing the general form of the electromagnetic field in a cubical conductive cavity with side length $$L$$:

The electric field in empty space must satisfy...the Maxwell equation $$\nabla\cdot\overrightarrow{\mathbf E}=0$$. The solution that satisfies the boundary conditions has components:$$E_x(\mathbf{rt})=E_x(t)\cos(k_xx)\sin(k_yy)\sin(k_zz),$$ $$E_y(\mathbf{rt})=E_y(t)\sin(k_xx)\cos(k_yy)\sin(k_zz),$$ $$E_z(\mathbf{rt})=E_z(t)\sin(k_xx)\sin(k_yy)\cos(k_zz).$$

The problem is, I don't see how this equation satisfies $$\nabla\cdot\overrightarrow{\mathbf E}=0$$ at all. Specifically, it seems like the value of the lhs of that equation is$$-(E_x(t)+E_y(t)+E_z(t))(\sin(k_xx)\sin(k_yy)\sin(k_zz)).$$There's no reason that $$(E_x+E_y+E_z)$$ needs to be zero, but it also can't be true that $$\sin(k_xx)\sin(k_yy)\sin(k_zz)=0$$ for every point in the cavity. Can anyone tell me what I am missing here?

Your expression given for $$\, \vec{\nabla} \cdot \vec{E}(\vec{r}, t)\,$$ is wrong. It should instead read $$-\left(k_x E_x(t)+k_y E_y(t)+k_z E_z(t)\right)\left(\sin(k_x x) \sin(k_y y) \sin(k_z z)\right).$$ Thus the Maxwell equation $$\, \vec{\nabla} \cdot \vec{E}(\vec{r},t) =0 \,$$ implies $$\, k_x E_x(t)+k_y E_y(t)+k_z E_z(t)=\vec{k} \cdot \vec{E}(t) =0 \,$$ in conformity with eq. (1.1.6) of your textbook.