Energy of electromagnetic wave

Its given here that energy density of an electromagnetic wave is

$$\vec S=\frac{1}{\mu}(\vec E\times\vec B)$$

How is the above expression derived? And when did energy become a vector? I though work done was a scalar quantity.

I know how to find the energy density of waves on a string.

$$\mathcal{E}=\frac{1}{8\pi}\ (E^{2}+B^{2})$$
$$\vec{\nabla}\times \vec{B}=\frac{1}{c}\frac{\partial\vec{E}}{\partial t}+\frac{4\pi}{c}\,\vec{j}\\ \vec{\nabla}\times \vec{E}=-\frac{1}{c}\frac{\partial\vec{B}}{\partial t}$$ so that, multiplying the first one by $\vec{E}$ and the second one by $\vec{B}$ and subtracting them, $$\frac{1}{c}\,\vec{E}\cdot\frac{\partial\vec{E}}{\partial t}+\frac{1}{c}\,\vec{B}\cdot\frac{\partial\vec{B}}{\partial t}=-\frac{4\pi}{c}\,\vec{j}\cdot\vec{E}-(\vec{H}\cdot\vec{\nabla}\times \vec{E}-\vec{E}\cdot\vec{\nabla}\times \vec{H})$$ Using the vector identity $$\vec{H}\cdot\vec{\nabla}\times \vec{E}-\vec{E}\cdot\vec{\nabla}\times \vec{H}=-\vec{\nabla}\cdot(\vec{E}\times\vec{B})$$ you get $$\frac{1}{2c}\,\frac{\partial}{\partial t} E^{2}+B^{2}=-\frac{4\pi}{c}\,\vec{j}\cdot\vec{E}-\vec{\nabla}\cdot(\vec{E}\times\vec{B})$$ Then you define $$\vec{S}=\frac{c}{4\pi}\,\vec{E}\times\vec{B}$$ so that $$\frac{\partial}{\partial t} \frac{E^{2}+B^{2}}{8\pi}=-\vec{j}\cdot\vec{E}-\vec{\nabla}\cdot\vec{S}$$ Integrating both members over all the three-dimensional space, $$\frac{\partial}{\partial t}\ \int\frac{E^{2}+B^{2}}{8\pi}+\int\vec{j}\cdot\vec{E}=0$$ (the second term of the second member vanishes when you integrate over all space). Rewriting $\vec{j}\cdot\vec{E}$ as $$\vec{j}\cdot\vec{E}=e\vec{v}\cdot\vec{E}=\frac{d}{dt}\mathcal{E}_{kin}$$ you can see that the second integral is the time variation of the kinetic energy of the charges. Then the first one must be the time variation of the energy of the fields (as the total energy is conserved). So, first of all, $$\mathcal{E}=\frac{1}{8\pi}\ (E^{2}+B^{2})$$ is the energy density of the fields, and second of all, going back to the equation containing $\vec{S}$, $$\vec{S}=\frac{c}{4\pi}\,\vec{E}\times\vec{B}$$ must be the (vector) density of its flow. Should you know a bit about Lagrangian dynamics, you can more easily derive that expression from the Lagrangian of the electromagnetic field.
• This equations never get wrong, in the context of classical mechanics. As you can see, their derivation is given in full generality. The only two things that require care is (1) should you use the formalism in which the fields are complex, you must slightly modify the formulas, for example $\mathcal{E}=(8\pi)^{-1}(\vec{E}^{*}\cdot\vec{E}+\vec{B}^{*}\cdot\vec{B})$; (2) plane waves are not integrable over the whole space: their energy densities are well-defined, but their total energy is not. – Giorgio Comitini Feb 7 '16 at 12:07