> Find the electric potential in the middle of a square with side length $a$ and charge $Q$. If I put the origin in the middle of the square, for the potential I get: $$4\frac{1}{4\pi\epsilon_0}\int_0^\frac{a}{2}\int_0^\frac{a}{2}\frac{\sigma}{\sqrt{x^2 + y^2}}dxdy$$ ,where $\sigma$ is surface charge density. Then I'd proceed to change to polar coordinates, so I get something like: $$\frac{\sigma}{\pi\epsilon_0}\int_0^{\frac{\pi}{2}} \int_0^{\frac{a}{2\cos\varphi}} dr d\varphi=\frac{\sigma}{\pi\epsilon_0}\frac{a}{2}\int_0^{\frac{\pi}{2}}\frac{d\varphi}{\cos \varphi}$$ which is a divergent integral. What am I doing wrong?