## Student handout: Electrostatic potential of four point charges

Computational Physics Lab II 2022
Students write python programs to compute and visualize the potential due to four point charges. For students with minimal programming ability and no python experience, this activity can be a good introduction to writing code in python using numpy and matplotlib.
Consider a system consisting of four point charges arranged on the corners of a square in 3D Cartesian space of coordinates $(x,y,z)$.
1. Write a python function that returns the potential at any point in space caused by four equal point charges forming a square. Make the sides of the square parallel to the $x$ and $y$ axes and on the $z=0$ plane.

To do this you will need the expression for a the potential due to a single point charge $V= \frac{k_Cq}{r}$ where $r$ is the distance from the point charge. You will also need to use the fact that the total potential is the sum of the potentials due to each individual point charge.

2. Once you have written the above function, use it to plot the electrostatic potential versus position along the three cartesian axes.
3. Label your axes.
4. Work out the first non-zero term in a power series approximation for the potential at large $x$, small $x$, etc. Plot these approximations along with your computed potential, and verify that they agree in the range that you expect. Useful 1$^{st}$ order Taylor expansions are: \begin{eqnarray} \sqrt{1+\epsilon} &\sim& 1+\frac{\epsilon}{2} \\ \frac{1}{1+\epsilon} &=& 1-\epsilon \end{eqnarray} where $\epsilon$ is a small quantity.
Extra fun
Create one or more different visualizations of the electrostatic potential. For example a 2D representation in the $z=0$ plane.
More extra fun
Create a plot of the potential along a straight line that is not one of the axes. Hint: start from a line on the $z=0$ plane, then try a random straight line. You can use your browser for help.
Even more extra fun
Move the charges around (e.g., off the $z=0$ plane) and see what happens to your graphs
Dipole fun
Repeat the above (especially the limiting cases!) for four point charges in which half are positive and half negative, with the positive charges neighbors.