# Magnetic field from a coil (on Mathematica)

## Main Question or Discussion Point

Hello guys,

I'm trying to find the configuration of two circular coils in a configuration similar to Helmholtz coils that would homogenize the magnetic field best at a volume between them.

So the first thing step I took in that is use the Biot-Savart law to calculate the magnetic field produced at each point through that coil. The coordinate system is Cylinderical coordinates, and the coil is placed on the xy-plane, its center matches the origin (0,0,0).

The function is

$\begin{array}{l} dl = \sqrt {d{x^2} + d{y^2}} = Rd\theta \\ B\left( {\overrightarrow r } \right) = \frac{{{\mu _0}I}}{{4\pi {R^3}}}\int\limits_0^{2\pi } {\left( {\overrightarrow {dl} \times \left( {\overrightarrow r - \overrightarrow R } \right)} \right)d\theta } \\ B\left( {x,y,z} \right) = \frac{{{\mu _0}I}}{{4\pi {R^3}}}\int\limits_0^{2\pi } {\left( {\left( { - R\sin \theta ,R\cos \theta ,0} \right) \times \left( {x - R\cos \theta ,y - R\sin \theta ,z} \right)} \right)d\theta } \end{array}$

where r(x,y,z) is the position vector from origin to the point, at which the magnetic field is to be calculated; R is the radius of the coil.

I wrote a Mathematica script to do this integral, but it always gives a single number (representing a 2 pi R^2 constant result from the cross product and the integral), no matter how I change x,y and z. This is the function I'm using.

FieldAtPoint[x_, y_, z_] :=
(u0 i)/(4 Pi r^2)
Integrate[
Cross[r{-Sin[t], Cos[t], 0}, ({x - r Cos[t], y - r Sin[t], z})], {t,
0, 2 Pi}]
Do you find anything wrong within my calculations? Please advise. How do I do this correctly?

Thank you for any efforts.

Last edited: