Having established the magnetic field of the simplest cases, straight wires, we must go through some calculus before analyzing more complex situations. In this section we shall generate an expression for the small contribution of a segment of a wire to the magnetic field at a given point, and then show how to integrate over the whole wire to generate an expression for the total magnetic field at that point.
Consider a randomly shaped wire, with a current I running through it, as shown below. We want to find the magnetic field at a given point near the wire. First, we find the individual contributions of very small lengths of the wire, dl. The concept behind this method is that a very small piece of wire, no matter how the whole wire curves and twists, can be considered a straight line. So we sum over an infinite number of straight lines (i.e. integrate) to find the total field of the wire. If the distance between our small segment dl and the point is r, and the unit vector in this radial direction is denoted by , then the contribution by the segment dl is given by:
This equation is quite complicated, and is difficult to understand on a theoretical level. Thus, to show its applicability, we will use the equation to calculate something we already know: the field from a straight wire. We begin by drawing a diagram showing a straight wire, including an element dl, in relation to a point a distance x from the wire: From the figure, we see that the distance between dl and P is . In addition, the angle between and dl is given by sinθ = . Thus we have the necessary values to plug into our equation: