Charge density of line of length $L$ expressed with Dirac delta function in cylindrical coordinates

chargedensitydirac-delta-distributionselectrostatics

I want to find the charge density of a line charge of length $L$ in cylindrical coordinates.
I suppose charge density is independent of $\phi$. The line charge is only defined for coordinates of $z$ between $L/2$ and $-L/2$. So I suppose we can express the charge density as:

$$\rho(r,\phi,z)=f(r,z)\delta(r)\theta(L/2-|z|)$$

I want to find $f(r,z)$, so I can try to use the volume integral to find it. However, something must be wrong in my definition, as this integral integrates to zero:
$$Q=\int^{\infty}_{-\infty} \int^{2\pi}_{0} \int^{\infty}_{-\infty}f(r,z)\delta(r)\theta(L/2-|z|)~r~dz~d\phi~dr\\=\int^{\infty}_{-\infty} \int^{2\pi}_{0} f(r,z)\theta(L/2-|z|)~0~dz~d\phi=0$$

I can't find my mistake, and I would really appreciate your help.

By the way, I already know that $\rho=\frac{Q}{L}$, but I want to prove it with the cylindrical coordinates and delta function that I mentioned.

$\theta$ is the step function.

Best Answer

In order to compensate for the $r$ in the volume element $r\ dr\ d\phi\ dz$ you need a factor $\frac{1}{r}$ in your charge density $\rho$. And the over-all constant is adjusted so that the total volume integral will be $Q$. You finally get $$\rho(r,\phi,z)=\frac{Q}{2\pi rL}\delta(r)\theta(L/2-|z|)$$

The term $\frac{1}{2\pi r}\delta(r)$ might seem weird at first, but it is actually equal to $\delta(x)\delta(y)$. See also the math question Dirac delta in polar coordinates and its accepted answer.