These exercises are not tied to a specific programming language. Example implementations are provided under the Code tab, but the Exercises can be implemented in whatever platform you wish to use (e.g., Excel, Python, MATLAB, etc.).

### Exercise 1: Computing Electric Field Analytically
The electric field at a distance $r$ from the midpoint of a uniformly charged rod of length $L$ along an axis perpendicular to the rod is
$$E=\frac{1}{4\pi\varepsilon_0}\frac{Q}{r\sqrt{r^2+(L/2)^2}}$$
Suppose you have a vertically oriented rod of total charge $Q=+1\ \mu$C, centered at the origin with a length of 1 m. What is the electric field at the location $< 0.1 , 0 , 0 >$ m?
**Use $\frac{1}{4\pi\varepsilon_0}\approx9\times10^9\ \mathrm{N}\cdot \mathrm{m}^2/\mathrm{C}^2$ for all exercises.**
![rod](./images/efieldrod/rod.png)
### Exercise 2: Computing E-field Due to a Uniformly Charged Rod Numerically (By Hand)
To numerically compute the electric field at a point in space due to a uniformly charged rod, you must break the rod into small pieces and treat each piece as a point particle. Then, calculate the electric field due to each piece and use superposition to get the net electric field at the given point in space. In this exercise, you will calculate it by hand for a small number of pieces. In later exercises, you will use a computational tool that is far more efficient.
You have a vertically oriented rod of total charge $+Q=1\mu C$, centered at the origin with a length of 1 m. Break each half of the rod into 3 pieces for a total of 6 pieces. Calculate the net electric field at the location $< 0.1 , 0 , 0 >$ m by treating each piece as a particle. We'll call this point P. The figure below shows the electric field at point P due to the top piece of the rod.
![rod2](./images/efieldrod/rod2.png)
Here are the steps:
1. Sketch the rod, showing each piece. Label the pieces by numbering them 1 through 6.
2. Write the coordinates of the first piece < x , y , z >.
3. Calculate the position of point P relative to the center of the first piece, $\vec{r}$. Calculate the vector $\vec{r}$, the unit vector $\hat{r}$, and the magnitude $|\vec{r}|$, for point P relative to the center of the first piece.
4. Calculate the electric field at point P due to the first piece.
5. Repeat this calculation (steps 2-4) for each of the other pieces.
6. Calculate the net electric field at point P by summing the electric field due to each piece.
You should find that $\vec{E}_{net} = < 1.55\times10^5, 0, 0 >$ N/C.
How does this compare with the analytic result in Exercise 1?
What can you do to make the numeric result in this exercise more accurate?
### Exercise 3: Computing E-field Due to a Uniformly Charged Rod Numerically (With a Computer Program)
Note what a pain it would be if you broke the rod into 100 pieces and had to calculate electric field by hand! That's why you prefer to solve it analytically. However, not all charge distributions are easily solved analytically. Furthermore what if the point $P$ was not along an axis of symmetry? That's why we write computer programs to do the numeric calculation.
Write a computer program that computes the electric field for the situation as in Exercise 2 (with the rod broken into only 6 pieces). Compare the result given by your program to the result found in Exercise 2. It should be the same
### Exercise 4: Investigating the Effect of Smaller Piece Size
Your answer in Exercise 3 does not match the analytic result in Exercise 1 because the approximation of each piece of the rod being a *point particle* at the center of the piece is not accurate for large pieces. To use smaller piece sizes, we must break the rod into a larger number of pieces, $N$.
Increase $N$ and run your simulation (from Exercise 3) again. Make a data table showing the following values of $N$ and the resulting net electric field at the given point, $P$.
| $N$ | $\vec{E}_{net} \quad \mathrm{(N/C)}$ |
| -- | -- |
| 6 | |
| 10 | |
| 50 | |
| 100 | |
| 500 | |
| 1000 | |
What value of $N$ is sufficient to give a result that agrees within 1% of the analytic result from Exercise 1?
### Exercise 5: Computing the Electric Field at a Point On The Axis of the Rod
Using the same charge and length for the rod, calculate analytically the electric field at the location $< 0, 0.6 , 0 >$ m, that is along the axis of the rod. Use your program to numerically compute the electric field at the same point. Verify that you get a similar result, depending on the value of $N$ that you use.
### Exercise 6: Computing the Electric Field at Any Point in Space
The advantage of computing the electric field numerically is you can compute the electric field at any point P in space. What is the electric field at the location $< 0.1, 0.5 , 0 >$ m?