# Magnetic induction outside of the finite length solenoid

I'm programing simulation software for solenoid and hemholtz coils, where I have to calculate B(x,y,z). I have found dozens of variations of Biot-savart law for determining B on axis. But how about outside of the solenoid?

This is said to be outside of solenoid: $$B(z) = \frac{\mu_0}{4\pi}\cdot\frac{iR^2}{2(R^2+z^2)^{\frac{3}{2}}}$$
But why only z coordinate? What about length of solenoid? In order to build simulation, I have to count with finite-length solenoid.

There are hints, that I should apply line integral (curve integral?) to the biot-savart law. But what is that curve? The electric wire? So I have to use eliptic integral to have something close to the solenoid? I'm quite lost in all of this.

• In fact, it has a closed form after the integral. please check this website. Jan 18, 2016 at 12:42

The magnetic field of a single loop of current is exactly solvable both on- and off-axis, with the horrible disadvantage that the off-axis solution uses elliptic integral functions. The formula you quote seems to be the on-axis field of a single loop.

The exact solution is given in Jackson's Classical Electrodynamics, section 5.5, or in this webpage. From the latter, $$B_z = \frac{\mu_0 I}{2\pi}\frac{1}{\sqrt{(a+r)^2+z^2}}\left[E(k) \frac{a^2-r^2-z^2}{(a-r)^2+z^2}+K(k)\right]$$ is the on-axis component, while $$B_\rho = \frac{\mu_0 I}{2\pi}\frac{z/\sqrt{r^2-z^2}}{\sqrt{(a+r)^2+z^2}}\left[E(k) \frac{a^2+r^2+z^2}{(a-r)^2+z^2}-K(k)\right]$$ is the cylindrical polar radial component, where $a$ is the loop radius, $k=\sqrt{\frac{4ar}{(a+r)^2+z^2}}$, and $E(k)$ and $K(k)$ are complete elliptic integrals of the first and second kind, respectively.

This is right horrible but it is suitable for computational purposes. To find the field of a solenoid you should integrate this over an on-axis displacement of the ring. You could attempt this analytically (though I'm not aware of any exact solution) or numerically. The latter makes a bit more sense to me as your solenoid is of course a finite superposition of current loops (though of course those have a finite width).

The field above is for a single loop in the $x,y$ plane, centred at the origin. To perform the integration, you need to transform this result into the field of a loop around an arbitrary point on the $z$ axis. To do this, you need to change $z$ to the difference $z'=z-b$ and $r$ to the distance $$r'=\sqrt{x^2+y^2+(z-b)^2}=\sqrt{r^2+b^2-2bz}.$$ You also need to transform the field: the component $B_z$ is a cartesian component and transforms well, as does the cylindrical component $B_\rho$, but the spherical radial component $B_r$ from the previous version points away from the centre of the loop and needs to be transformed.

Once this is done, you integrate over $b$ from $-L/2$ to $L/2$. Note that this involves integrating nested square roots inside the elliptical integral functions, so it is unlikely to have a closed-form solution. I would urge you to consider a numerical integration scheme that views your solenoid as a finite (though possibly large) collection of current loops at different displacements $b$ and implementing the sum in your code.

If this is unacceptably complicated, and you have some specific limit in mind, look in Jackson. He gives expressions in the limit $k^2\ll1$ which he claims specialize well to the near-axis ($\theta\ll\pi$), near-the-centre ($r\ll a$) and far-field ($r\gg a$) cases, and do not involve elliptic integrals.

I hope this helps.

• Thank you for valuable answer! Should i integrate Br over Bx? That is: $B_{solenoid} = \int Br\ dBx$ but what will be the range (bounds) of integration? May 12, 2013 at 12:51
• @Fidilip Please see the revised post for details on the integration step from a loop to a solenoid. If you need further assistance, you should provide clearer details of what your problem is and what you expect to get out of the solutions you are asking about. May 12, 2013 at 18:41
• I think the expression for $B_\rho$ is incorrect. The $\sqrt{r^2 - z^2}$ should be replaced with $r$. In this case, the expression for $B_\rho$ is actually an expression for $B_r$, where $r$ is the radial distance in cylindrical coordinates, not spherical (otherwise the $B_z$ expression is also incorrect). This means that the transformation given in the second part is also not quite right, since you're using $r$ to mean distance from the origin instead of the $z$ axis. Mar 26, 2022 at 5:11
• Also a word of caution to anyone using these functions in a program like Mathematica or Matlab, many software packages use a different convention for elliptic integrals than is used here. To get sensible answers you have to replace $k$ with $k^2$ everywhere. Mar 26, 2022 at 5:13