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.
 A: That is not the energy density of the electromagnetic field. That is the energy flow density vector of the field, also known as the Poynting vector. Energy flows in some direction, so its density must be a vector. You're totally right, energy density is not a vector, and it is given in gaussian units as
$$
\mathcal{E}=\frac{1}{8\pi}\ (E^{2}+B^{2})
$$
As for the derivation, you can compare the energy densities and flows of the fields and charge distribution. From Maxwell's equations:
$$
\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.
