Quadrupole magnets, abbreviated as Q-magnets, consist of groups of four magnets laid out so that in the planar multipole expansion of the field, the dipole terms cancel and where the lowest significant terms in the field equations are quadrupole.
A stronger version with very little external field involves using a k=3 Halbach cylinder.
The steel is magnetized by a large electric current in the coils of tubing wrapped around the poles.
[1] At the particle speeds reached in high energy particle accelerators, the magnetic force term is larger than the electric term in the Lorentz force: and thus magnetic deflection is more effective than electrostatic deflection.
This situation is due to the laws of electromagnetism (the Maxwell equations) which show that it is impossible for a quadrupole to focus in both planes at the same time.
But if there is a space between them (and the length of this has been correctly chosen), the overall effect is focusing in both horizontal and vertical planes.
A lattice can then be built up enabling the transport of the beam over long distances—for example round an entire ring.
A charged particle beam in a quadrupole magnetic field will experience a focusing / defocusing force in the transverse direction.
The focusing strength is given by and particles in the magnetic will behave according to the ODE[2] The same equation will be true for the y direction, but with a minus sign in front of the focusing strength to account for the field changing directions.
The field in a normal quadrupole is such that the magnetic poles are arranged with an angle of 45 degrees to the horizontal and vertical planes.