# Physics with Calculus/Electromagnetism/Field Energy

A single test particle's potential energy, $U_{\mathrm {E} }^{\text{single}}$ , can be calculated from a line integral of the work, $q_{n}{\vec {E}}\cdot \mathrm {d} {\vec {\ell }}$ . We integrate from a point at infinity, and assume a collection of $N$ particles of charge $Q_{n}$ , are already situated at the points ${\vec {r}}_{i}$ . This potential energy (in Joules) is:

$U_{\mathrm {E} }^{\text{single}}=q\phi ({\vec {r}})={\frac {q}{4\pi \varepsilon _{0}}}\sum _{i=1}^{N}{\frac {Q_{i}}{\left\|{\mathfrak {\vec {r}}}_{i}\right\|}}$ where ${\vec {\mathfrak {r}}}_{i}={\vec {r}}-{\vec {r}}_{i},$ is the distance of each charge $Q_{i}$ from the test charge $q$ , which situated at the point ${\vec {r}}$ , and $\phi ({\vec {r}})$ is the electric potential that would be at ${\vec {r}}$ if the test charge were not present. If only two charges are present, the potential energy is $k_{e}Q_{1}Q_{2}/r$ . The total electric potential energy due a collection of N charges is calculating by assembling these particles one at a time:

$U_{\mathrm {E} }^{\text{total}}={\frac {1}{4\pi \varepsilon _{0}}}\sum _{j=1}^{N}Q_{j}\sum _{i=1}^{j-1}{\frac {Q_{i}}{r_{ij}}}={\frac {1}{2}}\sum _{i=1}^{N}Q_{i}\phi _{i},$ where the following sum from, j = 1 to N, excludes i = j:

$\phi _{i}={\frac {1}{4\pi \varepsilon _{0}}}\sum _{j=1(j\neq i)}^{N}{\frac {Q_{j}}{4\pi \varepsilon _{0}r_{ij}}}.$ This electric potential, $\phi _{i}$ is what would be measured at ${\vec {r}}_{i}$ if the charge $Q_{i}$ were missing. This formula obviously excludes the (infinite) energy that would be required to assemble each point charge from a disperse cloud of charge. The sum over charges can be converted into an integral over charge density using the prescription $\sum (\cdots )\rightarrow \int (\cdots )\rho \mathrm {d} ^{3}r$ :

$U_{\mathrm {E} }^{\text{total}}={\frac {1}{2}}\int \rho ({\vec {r}})\phi ({\vec {r}})\operatorname {d} ^{3}r={\frac {\varepsilon _{0}}{2}}\int \left|{\mathbf {E} }\right|^{2}\operatorname {d} ^{3}r$ ,

This second expression for electrostatic energy uses the fact that the electric field is the negative gradient of the electric potential, as well as vector calculus identities in a way that resembles integration by parts. These two integrals for electric field energy seem to indicate two mutually exclusive formulas for electrostatic energy density, namely ${\frac {1}{2}}\rho \phi$ and ${\frac {\varepsilon _{0}}{2}}E^{2}$ ; they yield equal values for the total electrostatic energy only if both are integrated over all space.