# Multipole magnet

Multipole magnets are magnets built from multiple individual magnets, typically used to control beams of charged particles. Each type of magnet serves a particular purpose.
* Dipole magnets are used to bend the trajectory of particles
* Quadrupole magnets are used to focus particle beams
* Sextupole magnets are used to correct for chromaticity introduced by quadrupole magnets

## Magnetic field equations

The magnetic field of an ideal multipole magnet in an accelerator is typically modeled as having no (or a constant) component parallel to the nominal beam direction ($z$ direction) and the transverse components can be written as complex numbers:
$B_{x}+iB_{y}=C_{n}\cdot (x-iy)^{n-1}$
where $x$ and $y$ are the coordinates in the plane transverse to the nominal beam direction. $C_{n}$ is a complex number specifying the orientation and strength of the magnetic field. $B_{x}$ and $B_{y}$ are the components of the magnetic field in the corresponding directions. Fields with a real $C_{n}$ are called 'normal' while fields with $C_{n}$ purely imaginary are called 'skewed'.
First few multipole fields :
| n | name |
| 1 | dipole |
| 2 | quadrupole |
| 3 | sextupole |

## Stored energy equation

For an electromagnet with a cylindrical bore, producing a pure multipole field of order $n$, the stored magnetic energy is:
$U_{n}={\frac {n!^{2}}{2n}}\pi \mu _{0}\ell N^{2}I^{2}.$
Here, $\mu _{0}$ is the permeability of free space, $\ell$ is the effective length of the magnet (the length of the magnet, including the fringing fields), $N$ is the number of turns in one of the coils (such that the entire device has $2nN$ turns), and $I$ is the current flowing in the coils. Formulating the energy in terms of $NI$ can be useful, since the magnitude of the field and the bore radius do not need to be measured.
Note that for a non-electromagnet, this equation still holds if the magnetic excitation can be expressed in Amperes.

### Derivation

The equation for stored energy in an arbitrary magnetic field is:
$U={\frac {1}{2}}\int \left({\frac {B^{2}}{\mu _{0}}}\right)\,d\tau .$
Here, $\mu _{0}$ is the permeability of free space, $B$ is the magnitude of the field, and $d\tau$ is an infinitesimal element of volume. Now for an electromagnet with a cylindrical bore of radius $R$, producing a pure multipole field of order $n$, this integral becomes:
$U_{n}={\frac {1}{2\mu _{0}}}\int ^{\ell }\int _{0}^{R}\int _{0}^{2\pi }B^{2}\,d\tau .$
Ampere's Law for multipole electromagnets gives the field within the bore as:
$B(r)={\frac {n!\mu _{0}NI}{R^{n}}}r^{n-1}.$
Here, $r$ is the radial coordinate. It can be seen that along $r$ the field of a dipole is constant, the field of a quadrupole magnet is linearly increasing (i.e. has a constant gradient), and the field of a sextupole magnet is parabolically increasing (i.e. has a constant second derivative). Substituting this equation into the previous equation for $U_{n}$ gives:
$U_{n}={\frac {1}{2\mu _{0}}}\int ^{\ell }\int _{0}^{R}\int _{0}^{2\pi }\left({\frac {n!\mu _{0}NI}{R^{n}}}r^{n-1}\right)^{2}\,d\tau ,$
$U_{n}={\frac {1}{2\mu _{0}}}\int _{0}^{R}\left({\frac {n!\mu _{0}NI}{R^{n}}}r^{n-1}\right)^{2}(2\pi \ell r\,dr),$
$U_{n}={\frac {\pi \mu _{0}\ell n!^{2}N^{2}I^{2}}{R^{2n}}}\int _{0}^{R}r^{2n-1}\,dr,$
$U_{n}={\frac {\pi \mu _{0}\ell n!^{2}N^{2}I^{2}}{R^{2n}}}\left({\frac {R^{2n}}{2n}}\right),$
$U_{n}={\frac {n!^{2}}{2n}}\pi \mu _{0}\ell N^{2}I^{2}.$