In cylidrical coordinates,the magnetic field around an infinite (thin) current-carrying wire is $\vec{B} =\frac{\mu_0I}{2 \pi r} \hat{\phi}$
Naiively computing the curl of this using Curl$\vec{B}$ = $\begin{vmatrix} \frac{1}{\rho}\hat{\rho} & \hat{\phi} & \frac{1}{\rho}\hat{z} \\ \frac{\partial}{\partial\rho} & \frac{\partial}{\partial \phi} & \frac{\partial}{\partial z} \\ B_\rho & \rho B_\phi & B_z \end{vmatrix}$ gives zero (taking $r = \rho$).
Plugging this into Stokes' theorem gives a contradiction: $$\int \nabla \times \vec{B} \cdot dS = \oint \vec{B} \cdot dl \neq 0$$
My question is: what's gone wrong and why? I'm not sure if my calculation of the curl was invalid (maybe it's supposed to give a delta function) or whether Stokes' theorem is inapplicable here.
Specifically, I'd like some advice on what areas of maths to read up on to fully understand this.
I'm actually a physics student and issues like this come up all the time (eg Aharanov Bohm effect). I'm hoping a good answer to this question will help other physics students know what maths they need to read up on to understand this.
Edit:
I'm particularly interested in knowing the consistent correct maths to describe this situation.
Further Edit:
I think my question is really "is there an extension to Stokes' theorem when the function has poles?" and as a vaguely related question "how does Stokes' theorem generalise to spaces with points removed?". I'd love some direction on what area of maths this comes under.
Having reviewed some complex analysis, it looks like the whole theory should have a real analogue on 2D surfaces.
This is not wrong, but the kernel of field theories. There exists (distributional singular) fields with $\text{div} f=0$ and $\text{curl} v =0 $ that nevertheless have constant surface integrals
$$\int_{S^2} r^{-2} * r^2 d \Omega =4 \pi$$ $$\int_{S^1} r^{-1} * r d\phi = 2\pi$$
By linearity, the superposition of such fields by an integral with a smooth density of charges currents yields the solution of the Maxwell equations for such a static setting.