# Numerical Calculation for Work Done Near a Dipole

I’ll be honest. This connection between the electric potential (change in electric potential) and the electric field can get sort of crazy. But let’s just start with a problem and then solve it in more ways than you wanted.

Here is the problem.

Let’s start with the energy to bring an electron to point B. The energy needed would be equal to the change in electric potential energy which is equal to:

$\Delta U_E = q\Delta V$

That means I just need to calculate the change in electric potential from infinity to point B. Yes, you could also calculate the work needed to move the charge—I’ll do that also.

Since I am dealing with two point charges, I can use the following expression for the potential due to a point charge (with respect to infinity):

$V = k\frac{q}{r}$

Where k is the Coulomb constant ($k = 9 \times 10^9 \text{ Nm}^2\text{/C}^2$ and r is the distance from the point charge to the final location. Since there are two point charges, the total potential will just be the sum of the two potentials. Let me call the positive charge “1” and the negative charge “2”. That means the total potential will be:

$V = V_1 + V_2 = k\frac{q_1}{r_1} +k\frac{q_2}{r_2}$

From the original problem, $q_1 = 2 \times 10^{-9}\text{ C}$ and $q_2 = -2 \times 10^{-9}\text{ C}$. The distance $r_1$ will be 6 mm and the distance $r_2$ will be 4 mm (need to convert these to meters).

Putting this all together, I get the following. I will do my calculations in python. Here is the code.

Running gives the following output.

Boom. There is your first answer. What about point A instead of B? Well, in this case, I just have different distances. The distance for both $r_1$ AND $r_2$ are the same. Since they have the same distances but equal and opposite charges, the two potentials will be opposite. When added together, the total potential is zero volts. Yes, the energy needed to put a point charge at A from infinity is zero Joules.

What? Yes. How about this? Suppose you take the electron from infinity on the positive y-axis. As you move down the axis to point A, the electric field is in the x-direction. That means the electric force is in the negative x-direction. You would have to push it in the positive x-direction and move in the y-direction. But that requires ZERO work since the force and displacement are perpendicular.

Oh. You want to get to A from a point of infinity on the positive x-axis? OK. That still works. Remember that for electric potential, the path doesn’t matter—only the change in position (path independent). I can take whatever path I like. I’m going to move in a circle from positive infinity x to positive infinity y. The electric field is zero out there, so that requires zero work. Now I’m at positive infinity y—and I just did that problem. Zero work.

Another way—by calculating the work

Remember that work-energy principle? It says this:

$W = \Delta E$

And the work can be defined as the following (if the force and displacement are constant):

$W = F\Delta s \cos \theta$

Oh, and the force will be the opposite of the electric force where:

$\vec{F} = q\vec{E}$

So, as you push a charge towards point B (point A is boring—for now) the electric field changes. That means we have a problem. We can’t use the above formula to calculate the work—unless we cheat. Let’s cheat.

Instead of calculating the total work to move the charge to point B, I’m just going to move it a tiny bit. During this tiny move, the electric field (and thus the force) will be approximately constant. Then I can do another tiny move. Keep repeating this until I get to point B. Here is a diagram.

If this distance is short ($\Delta \vec{s}$) then the force is approximately constant. That means the tiny amount of work (which I will call $\Delta W$) would be equal to:

$\Delta W = eE\Delta s$

OK, just to be clear. This is the force needed to PUSH the electron (with a charge e)—it’s not the electric force on the electron (which is in the opposite direction). Also, the angle between F and the displacement is zero. That means the cosine term is just one. I wrote the force and displacement as scalars because it’s just the magnitude that matters.

Now we are ready for some stuff. Here are the steps I am going to use.

• Start at some position far away (but not actually infinity because that would be crazy). It just needs to be far enough away such that the electric force is negligible.
• Calculate the total electric field and the force needed to push the electron at this point.
• Move some short distance towards point B.
• Over this distance, assume the force is constant and calculate the small work done—add this to the total work.
• Repeat until you get to point B.

Before making this one program, I’m going to just make a program to plot the electric field from some value up to point B. Here is the plot from that program. (here is the code)

Note that I started from just 5 cm away from the origin—which is TOTALLY not infinity. However, it makes the graph look nice. But still, this is good because it looks like the calculation is working. Now I can use this same calculation go find the work needed to move the electron. Here is the code.

And the output:

Notice that gives a close, but wrong answer (compared to my previous calculation). Why is it wrong? Is it because I started at y = 0.5 meters (I just realized I’ve been using the variable y instead of x—but it should be fine). Or is it wrong because my step size is too big?

The answer can be found by just changing up some stuff. If you move the starting point to 1 meter, you get about the same answer. However, if you change dy to 0.0001, you get the following output.

That works. Oh, I added some more stuff to the output.

Non-straight Path

One more thing (and then I will look at the electric field in another post). What if I use a different path to get to point B? Instead of coming along the x-axis (which I previously called “y”), I come parallel to the axis a distance of 2 mm above it. Once I get right over point B, I turn down.

Like this.

This introduces some “special” problems.

• I can break this path into two straight pieces (path 1 is parallel to x-axis and path 2 is parallel to y-axis).
• Along path 1, the force needed to push the electron is NOT parallel to the path. So, the angle is not zero in $\cos \theta$. This means I’m going to have to calculate the actual vector value of the electric field at every step along this path.
• The same is true along path 2.
• But in the end, I should get the same work required—right?

OK, hold on because this is going to get a little more complicated. Let me just include one sketch and then I will share the code for this new path. Here is how to calculate the electric field and work for a particular step in path 1.

Here’s what needs to happen to calculate the electric field (and force) for each step:

• Find the vector from the positive charge to step location.
• Use this vector to find a unit vector (to give the electric field a direction).
• Use that vector to also find the magnitude of the electric field.
• Calculate the electric field due to the positive charge (as a vector).
• Repeat this for the negative charge.
• Add the two vector values for the electric field to get the total electric field.
• Multiply by the charge to get the force (which would be in the opposite direction).

Now, to calculate the work done during each small step, I could use the angle between the force and displacement. But I don’t know that. Instead, I can use the vector definition of work:

$W = \vec{F} \cdot \Delta \vec{s}$

Yes, that is the dot product. Fortunately, the dot product is already built into VPython (Glowscript). So, once I get a vector value for the force and the displacement I can just use the “dot()” function.

OK, let’s do it. Here is the code (warning—vector stuff in the code) and the output.

Wow. I didn’t think that would work the first time. I’m pumped.

OK, the real reason for this post was to look at the connection between the electric field and the change in electric potential. I’ll make that in a follow up post.

## One thought on “Numerical Calculation for Work Done Near a Dipole”

This site uses Akismet to reduce spam. Learn how your comment data is processed.