What is the magnetic field at some point a distance a from a straight current-carrying wire? We'll split the wire up into pieces of length dx, figure out the field from each piece, and add them up (i.e., integrate) to find the net field.

Define a coordinate system with +x right, +y up, and +z out of the screen. The current is in the +x direction. Put the origin on the wire such that the point where we're calculating field is on the y-axis.

The magnetic field dB from a representative piece of the wire is:

**dB** = (m_{o} / 4p ) I **dx** ´
/r^{2}

What direction is this field?

The nice thing about this situation is that the field from every part of the wire points in the same direction, out of the page. This means that:

**dx** ´ = dx sin(q)

where q is the angle between the wire and the vector **r** pointing from ds to the point where we're calculating field.

Our integral for the net field becomes:

**B** = ( m_{o} I / 4p ) ò dx sin(q)
/r^{2}

We have too many variables (x, q, and r) so let's put everything in terms of q.

a = r sin(q), so r = a/sin(q) = a csc(q)

tan(q) = -a/x so x = -a/tan(q) or x = -a cot(q)

This gives dx = a csc^{2}(q) dq

With these substitutions the integral becomes:

**B** = ( m_{o} I / 4p ) ò a csc^{2}(q) sin(q) dq
/[a^{2} csc^{2} (q)]

**B** = ( m_{o} I / 4pa ) ò sin(q) dq

where the limits on the integral run from q_{1} at the left end of the wire to q_{2} at the right end.

Integrating sin(q) gives -cos(q), so the result of the integral is:

**B** = ( m_{o} I / 4pa ) [cos(q_{1}) - cos(q_{2}]