2.4 Find the electric field a distance \(z\) above the centre of a square loop with a side length of \(2a\) carrying a uniform line charge \(\lambda\).
$$d\vec{E}_1 = \frac{\lambda}{4 \pi \epsilon_0} \left( \frac{ x \, dx}{ (a^2 + z^2 +x^2)^{3/2}} \, \hat{i} + \frac{ -a \, dx}{ (a^2 + z^2 +x^2)^{3/2}} \, \hat{j} + \frac{ z \, dx}{ (a^2 + z^2 +x^2)^{3/2}} \, \hat{k} \right)$$
$$d\vec{E}_2 = \frac{\lambda}{4 \pi \epsilon_0} \left( \frac{ -a \, dy}{ (a^2 + z^2 +y^2)^{3/2}} \, \hat{i} + \frac{ y \, dy}{ (a^2 + z^2 +y^2)^{3/2}} \, \hat{j} + \frac{ z \, dy}{ (a^2 + z^2 +y^2)^{3/2}} \, \hat{k} \right)$$
$$d\vec{E}_3 = \frac{\lambda}{4 \pi \epsilon_0} \left( \frac{ x \, dx}{ (a^2 + z^2 +x^2)^{3/2}} \, \hat{i} + \frac{ a \, dx}{ (a^2 + z^2 +x^2)^{3/2}} \, \hat{j} + \frac{ z \, dx}{ (a^2 + z^2 +x^2)^{3/2}} \, \hat{k} \right)$$
$$d\vec{E}_4 = \frac{\lambda}{4 \pi \epsilon_0} \left( \frac{ a \, dy}{ (a^2 + z^2 +y^2)^{3/2}} \, \hat{i} + \frac{ y \, dy}{ (a^2 + z^2 +y^2)^{3/2}} \, \hat{j} + \frac{ z \, dy}{ (a^2 + z^2 +y^2)^{3/2}} \, \hat{k} \right)$$
$$d\vec{E} = d\vec{E}_1 + d\vec{E}_2 + d\vec{E}_3 + d\vec{E}_4$$
$$\vec{E} = \frac{\lambda}{4 \pi \epsilon_0} \left( \int_{-a}^a \frac{2 x \, dx}{ (a^2 + z^2 +x^2)^{3/2}} \, \hat{i} + \int_{-a}^a \frac{ 2 y \, dy}{ (a^2 + z^2 +y^2)^{3/2}} \, \hat{j} + \cdots \\ \cdots + \int_{-a}^a \frac{ 2 z \, dx}{ (a^2 + z^2 +x^2)^{3/2}} \, \hat{k} + \int_{-a}^a \frac{ 2 z \, dy}{ (a^2 + z^2 +y^2)^{3/2}} \, \hat{k} \right)$$
Since the functions in the integrands for the \(\hat{i}\) and \(\hat{j}\) components are odd both integrals are zero (why?). Therefore,
$$\vec{E} = \frac{\lambda}{4 \pi \epsilon_0} \left(\int_{-a}^a \frac{ 2 z \, dx}{ (a^2 + z^2 +x^2)^{3/2}} + \int_{-a}^a \frac{ 2 z \, dy}{ (a^2 + z^2 +y^2)^{3/2}} \right) \hat{k}$$
Since both integrals are of the same form one can be computed and then multiply the result by 2. Also, because the integrands are even
$$\int_{-a}^a \frac{ 2 z \, dx}{ (a^2 + z^2 +x^2)^{3/2}} = 2 \int_0^a \frac{ 2 z \, dx}{ (a^2 + z^2 +x^2)^{3/2}}$$
Using a trigonometric substitution
$$x = \sqrt{a^2 + z^2} \tan \theta \hspace{10mm} dx = \sqrt{a^2 + z^2} \sec^2 \theta \, d \theta$$
$$4 \int \frac{ z \sqrt{a^2 + z^2} \sec^2 \theta \, d \theta}{ (a^2 + z^2)^{3/2} ( 1 + \tan^2 \theta)^{3/2}}$$
$$4 \int \frac{ z \sec^2 \theta \, d \theta}{ (a^2 + z^2) \sec^3 \theta}$$
$$\frac{ 4 z }{ (a^2 + z^2) } \int \cos \theta \, d \theta = \frac{ 4 z }{ (a^2 + z^2) } \sin \theta $$
back substituting
$$\frac{ 4 z }{ (a^2 + z^2) }\left( \frac{ x }{ \sqrt{ a^2 + z^2 + x^2} } \Big|_0^a \right) = \frac{ 4 a z }{ (a^2 + z^2) \sqrt{2 a^2 + z^z}}$$
$$\vec{E} = \frac{\lambda}{4 \pi \epsilon_0} \frac{ 8 a z }{ (a^2 + z^2) \sqrt{2 a^2 + z^z}} \, \hat{k}$$