[Physics] magnetic field due to current in a wire using Biot-Savart’s law

calculuselectric-currentelectromagnetismmagnetic fields

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
enter image description here

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.

Best Answer

The minus sign is wrong.The reason for this is the x which you have chosen to be positive but is in fact negative.
x points positively to the right and negatively to the left,and the horizontal vector that you are using in your picture is opposite to the direction of x.So,its x=-acotθ.
Cheers!