# Derivation: B-Field inside a Current-Carrying Coil

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:

Formula anchor

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.

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:

Ampere-law integral with a rectangular loop around the coil
Formula anchor

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:

Ampere's law with two remaining integrals
Formula anchor

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:

Integral over the path within the coil
Formula anchor

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

Ampere's law for a current-carrying coil
Formula anchor

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:

Ampere's law for a current-carrying coil with constant magnetic field
Formula anchor

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$$:

Ampere's law for a current-carrying coil with calculated integral
Formula anchor

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}$$:

Formula anchor

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.

## The Most Useful Physics Formula Collection on the Internet

+ Perfect for high school and undergraduate physics students
+ Contains over 500 illustrated formulas on just 140 pages
+ Contains tables with examples and measured constants
+ Easy for everyone because without vectors and integrals