Alexander Fufaev
My name is Alexander FufaeV and here I will explain the following topic:

B-Field inside a Current-Carrying Coil

Current-carrying coil with dimensions and magnetic field
Current-carrying coil that generates a magnetic field.

Our goal is to determine the magnitude of the magnetic field \( \class{violet}{B} \) within a coil through which a current \( \class{red}{I} \) is flowing. The coil has length \(l\) and \(N\) turns.

To calculate the magnetic field inside, we use the fourth Maxwell equation of electrostatics in integral form:

Here \( \class{red}{I} \) is the current enclosed by any closed oriented path \( \mathcal{S} \). We choose \( \mathcal{S} \) so that the integral 1 is as easy as possible to compute. To do this, we form a rectangular loop around the coil as shown in Illustration 2.

Integration path for the magnetic field of a long coil
Chosen rectangular loop as integration path. The loop is "pierced" by the current \(N\) times.

The path is oriented counterclockwise and is composed of four straight paths \( \class{gray}{\mathcal{S}_{1}} \), \( \class{brown}{\mathcal{S}_{2}} \), \( \class{gray}{\mathcal{S}_{3}} \) and \( \class{brown}{\mathcal{S}_{4}} \). You put the path \( \class{brown}{\mathcal{S}_{4}} \) so that it is inside the coil and the path \( \class{brown}{\mathcal{S}_{2}} \) outside the coil and thus parallel to \( \class{brown}{\mathcal{S}_{4}} \). Thus the integral to be solved becomes:

The first and the third integral over \( \class{gray}{\mathcal{S}_{1}} \) and \( \class{gray}{\mathcal{S}_{3}} \) are zero, because the magnetic field is perpendicular to the respective path and the scalar product in the integral vanishes. The other two integrals remain:

We choose a rectangular loop such that the paths \( \class{gray}{\mathcal{S}_{1}} \) and \( \class{gray}{\mathcal{S}_{3}} \) are very long. Thus the integral over \( \class{brown}{\mathcal{S}_{2}} \) is omitted because it is so far away from the coil that the magnetic field is approximately zero at this distance. What remains is only the integral over the path \( \class{brown}{\mathcal{S}_{4}} \) inside the coil:

Since the coil usually has \( N \) turns, the current "passes through" the loop \( N \)-times. The current contribution \( \class{red}{I} \) is \(N\)-times:

We assume that the magnetic field \( \class{violet}{\boldsymbol{B}} ~=~ \class{violet}{B} \, \boldsymbol{\hat{e}}_{4} \) inside is constant. This allows us to pull it out of the integral:

We oriented the coil so that the unit vector \( \boldsymbol{\hat{e}}_{4} \), which specifies the magnetic field direction, is parallel to the infinitesimal path \( \text{d}\boldsymbol{s}_{4} = \text{d}s_{4} \, \boldsymbol{\hat{e}}_{4} \). Thus the scalar product between the unit vectors is \( \boldsymbol{\hat{e}}_{4} \cdot \boldsymbol{\hat{e}}_{4} = 1 \):

Here, in the second step, we exploited the fact that the integration path \( \class{brown}{\mathcal{S}_{4}} \) runs along the coil and thus corresponds to the coil length \( l \). Rearrange 7 for the magnetic field magnitude \( \class{violet}{B} \):

With this you can calculate the magnetic field of a long coil (long, so that boundary effects do not play a role) or rearrange the formula and calculate \( N \), \(l\) or \(\class{red}{I}\), depending on what you are looking for.