Finding the distance from a point a distance $z$ above the center of a square to any point on the edge

electromagnetismphysicstrigonometryvectors

I was working on an electrostatics problem that I thought I was doing correctly. However, upon reading the solution I see I was not. I will post my attempt and the solution below and then ask a few (math pertinent) questions about both my attempt and the solution provided. I would greatly appreciate any help in understanding this problem. Thanks!

Problem Statement

Find the electric field a distance $z$ above the center of a square loop (side length $a$) carrying uniform line charge $\lambda$.

enter image description here


My attempt

Well, first I knew that the $x$ and $y$ components would cancel due to symmetry so that only leaves the $z$ component. For the $z$ component itself I noted that there are $4$ line segments of equal length (hence equal charge) and so we could calculate the electric field due to one segment then just multiply it by $4$ (since each contribution would be pointing in the positive $z$ direction). Doing so yielded $$E_z = \frac{1}{\pi\epsilon_0}\int_{-\frac{a}{2}}^{\frac{a}{2}} \frac{\lambda dx}{R^2}\sin\theta \hat{z} = \frac{1}{\pi\epsilon_0}\int_{-\frac{a}{2}}^{\frac{a}{2}} \frac{\lambda dx}{(z^2 + (\frac{a}{2}^2)}\frac{z}{\sqrt{(z^2 + (\frac{a}{2})^2}} \hat{z} = \frac{1}{\pi\epsilon_0}\int_{-\frac{a}{2}}^{\frac{a}{2}} \frac{\lambda z dx}{(z^2 + (\frac{a}{2})^2)^{\frac{3}{2}}} \hat{z} = \frac{\lambda z}{\pi\epsilon_0(z^2 + (\frac{a}{2})^2)^{\frac{3}{2}}}[x]\vert^{\frac{a}{2}}_{-\frac{a}{2}} = \frac{\lambda z a}{\pi\epsilon_0(z^2 + (\frac{a}{2})^2)^{\frac{3}{2}}}$$

Where the distance from the center of an edge to the point $P$ is given by $R = \sqrt{z^2+ (\frac{a}{2})^2}$ and I implicitly multiplied by $4$ from the start by writing $\frac{1}{\pi\epsilon_0}$


Provided Solution

They note the distance from $P$ to the center of the edge is also $R = \sqrt{z^2+ (\frac{a}{2})^2}$ and that the electric field due to one edge is then $$E_1 = \frac{1}{4\pi\epsilon_0}\frac{\lambda a}{\sqrt{z^2 + \frac{a^2}{4}}\sqrt{z^2 + \frac{a^2}{4} + \frac{a^2}{4}}}$$ Hence the total vertical contribution to the electric field is found by multiplying by $4\sin\theta = 4\frac{z}{\sqrt{z^2 \frac{a^2}{4}}}$ which yields $$E = \frac{1}{4\pi\epsilon_0}\frac{4\lambda az}{(z^2 + \frac{a^2}{4})\sqrt{z^2 + \frac{a^2}{2}}}$$


My questions

I would just like help seeing where they found the expression for the field contribution for one segment. In particular the expression for the distance between the point $P$ and the source charge. I feel like maybe it comes about from integrating with $x$-dependence in the denominator. It feels a bit "wrong" to not have any $x$-dependence in my expression for the distance since the distance will change as we integrate along the line charge. The only way I can think about incorporating this is: for every small increment moved on the $x$ axis, we would create a right triangle (in the xy plane) with opposite and adjacent sides defined by the distance from the center of the square in the plane (static), $\frac{a}{2}$, and the distance we've moved along the $x$-axis from $0$ (varying) such that the hypotenuse of that triangle in the xy-plane would then become the xy-component of the $3D$ triangle used to calculate the distance from the point $P$ to a point on the edge. But that seems quite cumbersome. Any help in understanding where their expression for the distance came from and/or how to account for varying distance as we move along the line charge will be greatly appreciated.

Best Answer

Your point $P$ is at $(0,0,z)$. Let's choose onlt the side at $y=a/2$. So any point on that side has coordinates $(x,a/2,0)$, where $x$ varies between $\pm a/2$. Then $$E_z = \frac{1}{4\pi\epsilon_0}\int_{-\frac{a}{2}}^{\frac{a}{2}} \frac{\lambda dx}{R^2}\sin\theta \hat{z} = \frac{1}{4\pi\epsilon_0}\int_{-\frac{a}{2}}^{\frac{a}{2}} \frac{\lambda dx}{(z^2 + (\frac{a}{2}^2)+x^2}\frac{z}{\sqrt{(z^2 + (\frac{a}{2})^2+x^2}} \hat{z}$$ To simplify calculations use $\alpha^2=z^2+(a/2)^2$. $$E_z=\hat z\frac{1}{4\pi\epsilon_0}\lambda z\int_{-\frac{a}{2}}^{\frac{a}{2}}\frac1{(\alpha^2+x^2)^{\frac32}}dx$$ A simple substitution $x/a=\tan u$ will give you the right answer

Related Question