Suppose there is a charge distribution that is half a circle with uniform charge. How do you find the electric field due to this half-ring? Here is a picture.

If you wanted to find the electric field at the origin (center of the half-ring), you could do this analytically. If you want to find the electric field somewhere else, you need to do a numerical calculation.

Here is the plan for the numerical calculation.

- Break the ring into N pieces (where N can be whatever number makes you happy).
- Treat each of these N pieces as though they were point charges.
- Calculate the electric field due to each of these pieces and add them all up.
- The end.

Maybe this updated picture will be useful.

Let’s say the total charge is 5 nC and the ring radius is 0.01 meters. We can find the electric field anywhere, but how about at < 0.03 ,0.04, 0 > meters.

I’m going to break this ring into pieces and let the angle θ determine the location of the piece. That means I will need the change in angular position from one point to the next. The total circle will go from θ = π/2 to 3π/2. The change in angle will be:

I know it’s wrong, but I will just put the first piece right on the y-axis and then space out the rest. Here is what that looks like for N = 7.

Here is the code.

That works. Oh, and here is the link to the code. Go ahead and try changing some stuff. See what happens if you put N = 20.

But there is a problem. If I make these charge balls, I need to also calculate the electric field due to each ball. I was going to make a list (a python list) to put all these balls in, but I don’t think I need it.

Here is my updated code.

With the output of:

I think this is working, but let me go over some of the deets.

- Line 13: you need to know the charge of each piece—this depends on the number of pieces.
- Line 12: We need to add up the total electric field from each piece. This means that we need to start with a zero electric field.
- Line 15: I named the point charges so I can reference them. But here you can see that with this method, there is only one charge—it just moves.
- Line 16: calculate r from a piece to observation location.
- Line 17: electric field due to a point charge.

**Homework**

I’m stopping here. You can do the rest as homework.

- How do you know this answer is correct? Hint: put the observation location at the origin.
- How many pieces do you need to get a valid answer?
- Make a plot of E vs. distance along the x-axis. This graph should show E approaching zero magnitude as you get farther away.
- What about electric potential with respect to infinity? Oh yeah. That’s a good one.
- Display the electric field as an arrow at different locations.