Application Center - Maplesoft

# Visualizing the electric field of a dipole

You can switch back to the summary page by clicking here.

electricDipole.mws

Visualizing Electric Dipole Fields

by Waterloo Maple, 2001

Let us assume there is an electric dipole with a unit positive charge at (0,0) and a unit negative charge at (.25, 0) . We plot the potential function , the equipotential lines and the electric field of the dipole. To conclude the demonstration, we show an animation of how the electric field evolves as the charges move closer together.

> restart: with(plots):

```Warning, the name changecoords has been redefined
```

The potential function for this dipole is . However, visualization of the electric field is problematic because of the singularities at the two poles. To help visualization, we add a small constant to the denominators of both terms.

> epsilon := .01;

Define the potential function

> pot := 1/sqrt(x^2+y^2+epsilon)-1/sqrt((x-.25)^2+y^2+epsilon);

Graph the potential function

> plot3d( pot, x=-.1..(.35), y=-.25..(.25), shading=zhue, orientation=[50,70], axes=boxed);

The equipotential lines, i.e. contours, of the potential function

> contourplot( pot, x=-.1..(.35), y=-.25..(.25), thickness=2, contours=15);

The electric field of the dipole, which is just a plot of the gradients of the potential function at various points in the plane.

> gradplot( pot, x=-.1..(.35), y=-.25..(.25), thickness=2, grid=[15,15], color=pot );

Finally, let's create an animation showing how the electric field changes as the negative charge approaches the positive charge, starting from the point (.5, 0)

> n := 40;

> for i from 1 to n do
pot[i] := 1/sqrt(x^2+y^2+epsilon)-1/sqrt((x-.5*(1-i/(n+.1)) )^2 + y^2 + epsilon);
pic[i] := gradplot( pot[i], x=-.1..(.6), y=-.25..(.25), thickness=2, grid=[15,15],color=pot[i] );
end do:

display( seq(pic[i], i=1..n), insequence=true);

>