The work done in rotating an electric dipole in a uniform electric field can be calculated using the formula:
\[
W = -\vec{p} \cdot (\vec{E}) \cdot (\cos \theta_2 - \cos \theta_1)
\]
Where:
- \(\vec{p}\) is the dipole moment,
- \(\vec{E}\) is the electric field,
- \(\theta_1\) is the initial angle,
- \(\theta_2\) is the final angle.
In this case, the dipole is initially aligned parallel to the electric field, so \(\theta_1 = 0^\circ\), and after rotating it through \(180^\circ\), \(\theta_2 = 180^\circ\). The dipole moment and electric field are parallel in the initial position, and the final position is antiparallel.
Substituting into the formula:
\[
W = -pE \left[ \cos 180^\circ - \cos 0^\circ \right]
\]
\[
W = -pE \left[ -1 - 1 \right] = 2pE
\]
Thus, the work done in rotating the dipole through an angle of \(180^\circ\) is:
\[
W = 2pE
\]