**Do you know that the energy is associated with a charge distribution . This associated energy is also known as Electrostatic Energy. Let us calculate this energy associated with charge distribution:
**

When a test charge is moved from a point of lower potential to a point of higher potential, the potential energy of the system increases. But, there is a decrease in potential energy when a test charge is moved from higher to lower potential.

The potential energy imparted to the system by external work on a charge when moved from lower to higher potential is

W=QV

Where W is the work done, Q is the test charge. To calculate the energy of a system say consisting of three points charges Q_{1},Q_{2},Q_{3} ,we first bring the charge Q_{1} from infinity to position 1,no work is done here as the field does not exist in the system.

Thus W_{1}=0

Similarly for q_{2}, work done ,W_{2}=Q_{2}V_{21}.where v_{2.1} is the potential at the location of Q_{2}due to Q_{1}.Also for Q_{3}we have W_{3}=Q_{3}V_{3.1}+Q_{3}.V_{3.2} where V_{3.1} and V_{3.2} are potentials at position 3 due to Q_{1} and Q_{2}respectively.

Total work done W=W_{1}+W_{2}+W_{3} (1)

=0+Q_{2}V_{2}V_{2.1}+Q_{3}V_{3.1}+Q_{3}V_{3.2}

If charges are brought in the reverse order then,

W=W_{3}+W_{2}+W_{1}=0+Q_{2}V_{2.3}+Q_{1}V_{1.3}+Q_{1}V_{1.2} (2)

Adding equations (2) and (3),we get

2W=Q_{1}V_{1.3}+Q_{1}v_{1.2}+Q_{2}V_{21}+Q_{2}V_{21}+Q_{3}V_{3.1}+Q_{3}V_{3.2 }(3)

V_{1.3}+V_{1.2} is the sum of potential at position Q_{1}due to charges Q_{3} amd Q_{2} respectively i.e total potential at Q_{1} is V_{1} .Similarly total potential at Q_{2 }ans Q_{3} is V_{2} and V_{3} respectively. Thus equation (3) can be written as

2W=Q_{1}V_{1}+Q_{2}v_{2}+Q_{3}V_{3}

Or W=1/2 (Q_{1}V_{1}+Q_{2}V_{2}+Q_{3}V_{3})

For large number of charges ,we have

W=1/2 ∑^{n}_{i=1}Q_{i}V_{i}

But for a continuous charge distribution, work done in a volume V having charge density ρ_{v} enclosed within a sphere of radius R is

W=1/2∫ρ_{v} VdV (Q=ρ_{v}dV)

W=1/2 ∫(del.D)VdV [ from Gauss’s law del.D=ρ_{v}] (4)

As per vector identity ,we know that

Del(del D)=(del D)V+D.(delV)

Or (Del.D)V=(del.VD)-(D.del V)

Put this equation in equation (4)

W=1/2 ∫(del.VD)dV-1/2∫(D.delV)dV (5)

Now for large R→∞,using divergence theorem

=1/2 ∫(Del.VD)dV =1/2 ∫VD.dS

At very large radius r,D=1/R^{2},V∞1/R so VD∞1/R^{3} and surface ∞R^{2}

Thus ½ ∫VD.dS=0 ( 1/2∫(1/R^{3})R^{2}=0)

From equation (s),we have

W=1/2 ∫(D.delV)dV

Since E=-del V

W=1/2 ∫(D.E)dV

Also D=ε_{0}E

Thus ,Energy W=1/2 ∫ε_{0}E^{2}dV

In the above expressions,it appears that each tiny volume dV be assigned the energy content WdV where

Energy density =E/dV

W_{E}=1/2 ε_{0}E^{2}

Here ε=ε_{0}ε_{r}

Energy Density,

W_{E}=1/2 ε_{0}ε_{r}E^{2}