# Electrical Energy Density Derivation

In this post, we’ll do a mathy proof of the electrical energy density of an electric field. Here’s the statement:

For any continuous distribution of charge where the electric field vanishes at infinity, the total electrical energy of the system is given by

$\displaystyle U = \int_{all \, space} \frac{1}{2} \epsilon_{0} E^{2} \, dV$

where $dV$ is a small volume element, $E$ is the electric field magnitude at a particular point, and the integral is taken over all space. This allows us to interpret the quantity

$\displaystyle \frac{1}{2} \epsilon_{0} E^{2}$

as the density of electrical energy.

To prove this, we first need to make sure we understand what the electrical energy means.

# what is electrical energy?

Here’s how we’ll define it.

The potential energy of a distribution of charge is the work that must be done to assemble it from a state where they are all infinitely far away from each other. The reason is simple: When they’re all infinitely far away, they’re not interacting at all!

For example, if I just had two charges, they’re infinitely far away from each other when one is at the origin and the other is at infinity. The potential energy is then the work I do to put the far away charge at a specified distance from the charge at the origin. Here’s another very important property. The path I take while bringing in the charge does not matter! This is because the electric field is conservative, which means that there is a well defined potential energy between two points.

Let’s say I have three charges as shown above. Then since the path you take to assemble the charge does not matter, you can have charge $A$ at the origin, bring in charge $B$, and then finally bring in charge $C$. Or you can fix charge $B$ and bring in $A$ and $C$ at the same time. It really doesn’t matter. For simplicity, we’ll go with the first option.

The work you do bringing $B$ beside $A$ is just the potential energy between $A$ and $B$. And then the work you do brining $C$ in front of $A$ and $B$ is just the sum of the potential energies between $A$ and $C$, and $B$ and $C$. So the total potential energy is just the sum of the potential energies between $A$ and $B$, $A$ and $C$, and $B$ and $C$.

### our first formula for energy

In words, The total energy of a system of point charges is the sum of the potential energies between each pair of charges.

Converting this into math,
$\displaystyle U = \frac{1}{2} \sum_{i = 1}^{N} \sum_{j \neq i} \frac{q_i q_j}{4 \pi \epsilon_0 r_{i,j}}$
Here we have labeled each point charge with an index from $1$ to $N$. The charge on the particle $i$ is $q_i$ and the distance between particle $i$ and particle $j$ is $r_{i,j}$.The factor of $1/2$ is there because we are over counting by a factor of $2$. For example, we will count both $i = 1, j = 2$ and $i = 2, j = 1$.

Notice we can rearrange the formula to get
$\displaystyle U = \frac{1}{2} \sum_{i=1}^{N} q_{i} \sum_{j \neq i}\frac{q_j}{4 \pi \epsilon_0 r_{i,j}}$
All we’ve done is factor out the $q_{i}$ from the sum over $j$. This equation now has some physical meaning.

$\displaystyle \sum_{j \neq i}\frac{q_j}{4 \pi \epsilon_0 r_{i,j}}$

is the potential energy at particle $i$ due to all other charges other than particle $i$. Let’s call this $\phi_{i}$. Then
$\displaystyle U = \frac{1}{2} \sum_{i = 1}^{N} q_i \phi_{i}$

If we aren’t dealing with point charges, we’re dealing with a continuos distribution of charge. In the continuum limit, the sum becomes an integral and $q_{i}$ becomes $\rho \, dV$, where $dV$ is a small volume element. So
$\displaystyle U = \frac{1}{2}\int_{R} \rho \phi \, dV$
Where $R$ just represents all of space.

By Gauss’s Law,
$\displaystyle \nabla \cdot \vec{E} = \frac{\rho}{\epsilon_0}$
where $\vec{E}$ is the electric field at a point not due to the infinitesimal charge located exactly at that point. If this is the definition, why should the gradient depend on the charge density at a certain point at all?

The answer is that Gauss’s Law takes the limit as we go infinitesimally close to our given point but never actually reach it. Therefore at these nearby points, $\phi$ always includes the contribution from the given point.

### the rest is math

Remembering that
$\displaystyle \vec{E} = -\nabla \phi$
$\displaystyle \nabla \cdot \nabla \phi = \nabla^{2} \phi = -\frac{\rho}{\epsilon_0}$

We can use this to simplify our integral further. Substituting
$\displaystyle \rho = -\epsilon_0 \nabla^{2} \phi$
the electrical energy becomes
$\displaystyle U = -\frac{1}{2}\int_{R} \epsilon_0 (\nabla^{2}\phi) \, \phi \, dV = -\frac{1}{2} \epsilon_0 \int_{R} \phi \nabla^{2}\phi \, dV$

###### A neat trick

We can simplify it as follows

$\displaystyle \phi \nabla^{2} \phi = \phi (\frac{\partial^{2} \phi}{\partial x^{2}} + \frac{\partial^{2} \phi}{\partial y^{2}} + \frac{\partial^{2} \phi}{\partial z^{2}} ) \\= \frac{\partial}{\partial x}(\phi \frac{\partial \phi}{\partial x}) - (\frac{\partial \phi}{\partial x})^{2} + \frac{\partial}{\partial y}(\phi \frac{\partial \phi}{\partial y}) - (\frac{\partial \phi}{\partial y})^{2}+\frac{\partial}{\partial z}(\phi \frac{\partial \phi}{\partial z}) - (\frac{\partial \phi}{\partial z})^{2} \\ = \nabla \cdot (\phi \nabla \phi) - (\nabla \phi) \cdot (\nabla \phi)$

This is just a straightforward calculation. You can easily verify it by going through the product rule and the definition of the gradient and divergence. Using this expression, the electrical energy becomes

$\displaystyle U = \frac{1}{2} \epsilon_0 ( \int_{R}(\nabla \phi) \cdot (\nabla \phi) \, dV)-\int_{R} \nabla \cdot (\phi \nabla \phi) \, dV)$

###### simplifying the integral

We can rewrite the first integral using the divergence theorem:

$\displaystyle \int_{R} \nabla \cdot (\phi \nabla \phi) \, dV = \int_{\partial R} \phi \nabla \phi \cdot \, d \sigma$

Here $\partial R$ is the surface of region $R$. For example, if $R$ were a sphere, then $\partial R$ would be the surface of the sphere. $d \sigma$ is a small vectorial area element perpendicular to the surface.

It turns out this integral is zero. Here’s why. Let’s imagine $R$ as a sphere of radius of $r$. Then we know $\phi$ falls off as $1/r$. Since $\nabla \phi$ is just the electric field, it falls off as $1/r^{2}$. The area grows as $r^{2}$, so the integral falls off as $(1/r)(1/r^{2})(r^{2}) = 1/r$. If we take $r \rightarrow \infty$, the integral vanishes.

This implies that

$\displaystyle U = \frac{1}{2} \epsilon_0 \int_{R}(\nabla \phi) \cdot (\nabla \phi) \, dV = \int_{R} \frac{1}{2} \epsilon_0 E^{2} \, dV$

where $E$ is the magnitude of the electric field (remember that $\nabla \phi = \vec{E}$).

We can interpret this as an energy density of

$\displaystyle \frac{1}{2} \epsilon_0 E^{2}$

associated with each volume $dV$, which is what we set out to prove.