magnetic field due to current in a wire using Biot-Savart's law

I am learning about Biot-Savart's law to calculate the magnetic field due to the electric current in a wire. $\displaystyle\mathbf{B}=\frac{\mu_0I}{4\pi}\int\frac{d\mathbf{s}\times\mathbf{\hat{r}}}{r^2}$ and I'm a little confused.

I'm examining a situation where the wire is infinitely long and lying on the X-axis with current running from left to right and I want to know the magnetic field at a point $P$ a distance $a$ above the wire on the Y-axis.

Using the right hand rule I see that $d\mathbf{s}\times\mathbf{\hat{r}}$ will be out of the page and equal in magnitude to $ds\sin\theta$. $r$ is equal to $\displaystyle\frac{a}{\sin\theta}$

That's pretty much all I know.. If I let $x$ be the distance from $-\infty$ to the origin then $x = a\cot\theta$ (why do I only take the distance from $-\infty$ to 0? or should I be multiplying this by two to get the distance from $-\infty$ to $+\infty$?). Then since $ds$ is on the X-axis it is equal to $dx$ but I only have $x$ so I take the derivative of $x$ which is $-a\csc^2\theta d\theta$. Substituting back into Biot-Savart's equation I get. $\displaystyle\mathbf{B}=\frac{\mu_0I}{4\pi}\int\frac{\sin\theta(-a\csc^2\theta d\theta)}{\frac{a^2}{\sin^2\theta}} = -\frac{\mu_0I}{4\pi a}\int\sin\theta d\theta$

If I then integrate from $\theta = 0$ at $x = -\infty$ to $\theta = \pi$ at $+\infty$ that integral equals 2 so now I have $\displaystyle\mathbf{B}=-\frac{\mu_0I}{2\pi a}$ which looks like the right answer except it's negative.

Can someone please explain to me where I'm making a mistake. Thank you!

UPDATE: here's a picture I made to help clarify UPDATE: I've been thinking about this and maybe my mistake is when I take the distance from $-\infty$ to 0 as $x$. If instead I take this as $-x$ then $dx$ is no longer negative. Is that right? I'm still confused why I would only take the distance of half of the wire. I saw an example at http://en.wikiversity.org/wiki/Biot-Savart_Law where they integrate with respect to $ds$ instead of $d\theta$ and it was a lot easier to follow.

• Draw a little diagram for yourself - I suspect that your sign goes awry in the transformation from $ds$ to $d\theta$ but without a picture it's hard to know for sure. – Floris Mar 28 '15 at 22:47