I have a very simple problem: There is a charge $-q$ at $(0, 0, d)$ and $(0, 0, -d)$ as well a charge $2q$ at $(0, 0, 0)$. I have to calculate the quadrupole moment using spherical coordinates. I use $x=\cos(\phi)$.
The formula I build up is this: $$ q_{2,m} = \frac{(2-m)!}{(2+m)!} \frac{(-1)^{m+1}}8 \int_{-1}^1 \mathrm dx \, \left(1-x^2\right)^{m/2} \frac{\mathrm d^{2+m}}{\mathrm dx^{2+m}} \left(x^2-1\right)^2 $$ $$\times\int_0^{2\pi} \mathrm d \phi \, \mathrm e^{\mathrm im \phi} \int_0^\infty \mathrm dr \, r^2 \rho(r, x, \phi).$$
Is this even correct?
Then I tried to figure out what the $\rho$ has to be, this is what I currently believe to be correct: $$ \rho(r, x, \phi) = q \delta(\phi) \left[2 \delta(r) \delta(x-1) - \delta(r-d) \delta(x-1) - \delta(r-d) \delta(x+1)\right].$$
So now I would just need to calculate the integrals, right? The problem for positive $m$ would be that $\int \mathrm dx \, \delta(x-1) \left(1-x^2\right)^{m/2}$ would be zero. And $\int \mathrm dr \, r^2 \delta(r)$ would also be zero. So the $q_{2,1}$ and $q_{2,2}$ are zero.
I previously used the following charge density (although there was a negative radius): $$ \rho(r, x, \phi) = q \delta(x) \delta(\phi) \left[2\delta(r) - \delta(d-r) - \delta(d+r)\right].$$
And I got: $$ q_{2,-2} = 3! q d^2 ,\quad q_{2,-1} = 0 ,\quad q_{2,0} = -q d^2 ,\quad q_{2,1} = 0 ,\quad q_{2,2} = \frac 14 qd^2. $$
In one of the books, it says that only the $Q_{3,3}$ element of the tensor would be non-zero.
So how can I obtain the correct answer here?