Biot-Savart law

The magnetic field produced by a current $I$ flowing through a wire can be determined by breaking the current path into short segments and adding all of the contributions of those segments together. The contribution to the magnetic field at position $\vec{r}$ due to a short segment of length $d\vec{s}$ at position $\vec{r}_{wire}$ is,

$\large d\vec{B}(\vec{r})=\frac{\mu_0}{4\pi}\frac{I d\vec{s} \times (\vec{r}-\vec{r}_{wire})}{|\vec{r}-\vec{r}_{wire}|^3}$ [T].

Here $d\vec{s}$ points in the direction that the current is flowing. The constant $\mu_0 = 4\pi \times 10^{-7}$ T m/A is the permeability constant.

The position and shape of the wire can be specified by parametric equations in terms of a parameter $s$ that measures the distance along the wire. For instance, a straight wire from $\vec{r}_1$ to $\vec{r}_2$ is described by,

$\large \vec{r}_{wire}=(r_{1x}+s(r_{2x}-r_{1x}))\hat{x} + (r_{1y}+s(r_{2y}-r_{1y}))\hat{y} + (r_{1z}+s(r_{2z}-r_{1z}))\hat{z}$  where $s=[0,1]$.

For a wire loop of radius $R$ in the $x$-$y$ plane at $z=0$,

$\large \vec{r}_{wire}=R\cos(2\pi s)\hat{x} + R\sin(2\pi s)\hat{y} + 0\hat{z}$  where $s=[0,1]$.

For a 10 turn spiral coil,

$\large \vec{r}_{wire}=R\cos(2\pi s)\hat{x} + R\sin(2\pi s)\hat{y} + \frac{s}{n} \hat{z}$  where $s=[0,10]$,

where $n$ is the number of turns per meter of the coil. The form below can be used to calculate the magnetic field at position $\vec{r}$ .

The position where $\vec{B}$ is calculated:

$\vec{r}=$ $\hat{x} +$ $\hat{y} +$ $\hat{z}$ [m].

The parametric equations that describe the wire:

$\vec{r}_{wire}=$ $\hat{x} +$ $\hat{y} +$ $\hat{z}$ [m].

$s$ is defined from $s=$ to $s=$ in segments.

The current: $I=$ [A].

The current is defined to be positive if it is flowing in the direction that $s$ increases.

$\vec{B}=$ $\hat{x} +$ $\hat{y} +$ $\hat{z}$ [T].

The 3-D plot shows the form of the wire. The longer the wire, the more segments are needed for an accurate answer. If the wire is a coil, about 300 segments per turn is appropriate.

The mathematical functions that can be used are list below. Multiplication must be specified with a '*' symbol, 3*cos(x) not 3cos(x). Powers are specified with the 'pow' function: x² is pow(x,2) not x^2.

  • abs(x) - absolute value
  • acos(x) - inverse cosine
  • asin(x) - inverse sine
  • atan(x) - inverse tangent
  • cos(x) - cosine
  • exp(x) - ex
  • log(x) - natural logarithm
  • pi = 3.141592653589793
  • pow(x,y) - compute xy
  • round(x) - round to the nearest integer
  • sin(x) - sine
  • sqrt(x) - square root
  • tan(x) - tangent
  • H(x) - Heaviside function