# Calculate the electric field above a ring of charge of radius `R` and charge density `lambda` at a point `P` centered on the axis of the ring.

In general, the contribution to the total electric field `E` from an infinitesimal piece of charge `dE` is

`dE=(k*dq)/r^2`

The total field is then calculated by integrating over all the charge:

`E=int(k*dq)/r^2`

Where `k=1/(4pi epsilon_0)` and `r` is the distance from `dq` to the point `P`

For this problem, if the point `P` is a distance `z` above the ring then we can set up a triangle to get a relationship between `z` and the distance `r`.

`r^2=z^2+R^2`

The vector `dE` pointing at point `P` from a chunk of charge, can be broken up into two components, one in the radial direction and one in the vertical direction.

`dE=dE_r+dE_z`

When considering the total electric field contribution from the ring, the radial contribution of every piece of charge will sum to zero and only the `z` contribution will be left due to the symmetry of the ring.

`dE_z=dE*cos(phi)=dE*(z/r)=(k*dq)/r^2*(z/r)`

`E_z=int(k*dq)/r^2 *(z/r)`

`E_z=int (k*z*dq)/r^3`

`lambda` is the piece of charge divided by a piece of length along the ring.

`lambda=(dq)/(dl)`

From the fact that `r*theta` is equal to the arc length around a circle we can say that

`dl=R*d(theta)`

Therefore,

`E_z=int (k*z*lambda dl)/r^3`

`E_z=int (k*z*lambda R d(theta))/r^3`

Now substitute for `r` and integrate theta from `[0,2pi]` .

`E_z=int_0^(2pi) (k*z*lambda R d(theta))/(sqrt(z^2+R^2))^3`

`E_z=(k*z*lambda R)/(sqrt(z^2+R^2))^3 int_0^(2pi) d(theta) `

`E_z=(2pi k*z*lambda*R )/(sqrt(z^2+R^2))^3`

Therefore the electric field at point `P` is entirely in the `z` -direction with magnitude:

`E_z=(z*lambda*R)/(2epsilon_0(sqrt(z^2+R^2))^3)`