In physics, the magnetic field is the field produced by a magnet. A field, in this context, is a vector field; that is, a vector for each point in space, possibly changing in time. Given the symbol B, the magnetic field points in the same direction as would a compass – away from the north pole of a magnet, and towards the north pole of the Earth.

Historically, B was called the magnetic flux density or the magnetic induction, and H (= B / &mu) was called the magnetic field, and this terminology is still often used to distinguish the two in the context of magnetic materials (non-trivial μ). Otherwise, however, this distinction is often ignored, and both symbols are frequently referred to as the magnetic field. (Some authors call H the auxiliary field, instead.)

Magnetic fields are produced by charges in motion, and moving charges are deflected by magnetic fields. The quantum-mechanical spin of a particle also produces a magnetic field—this is the source of the field in a ferromagnet.

Like the electric field, the magnetic field can be defined by the force it produces:

where "×" indicates a vector cross product, q is electric charge, and v is velocity. This law is called the Lorentz force law. The simplest mathematical statement describing how magnetic fields are produced makes use of vector calculus. In free space:

" ×" is curl, " ·" is divergence, μ0 is permeability, J is current, ∂ is the partial derivative, ε0 is the permittivity, E is the electric field and t is time. The first equation is known as Ampère's law with Maxwell's correction. The second term of this equation (Maxwell's correction) disappears in static or quasi-static systems. The second equation is a statement of the observed non-existence of magnetic monopoles. These are two of Maxwell's equations.

Maxwell did much to unify static electricity and magnetism, producing a set of four equations relating the two fields. However, under Maxwell's formulation, there were still two distinct fields describing different phenomena. It was Albert Einstein who, using special relativity showed that electric and magnetic fields are two aspects of the same thing (a rank-2 tensor), and that one observer may perceive a magnetic force where a moving observer perceives an electrostatic force. Thus, using relativity, magnetic forces may be predicted from knowledge of electrostatic forces alone. The equations given above are valid under relativity—indeed, their validity without relativity is questionable.

Technically, the magnetic field isn't a vector according to the formal definition, it is a pseudovector: it gains an extra sign flip under improper rotations of the coordinate system. (The distinction is important when using symmetry to analyze magnetic-field problems.) This is a consequence of the fact that B is related to two true vectors by a cross product (e.g. in the Lorentz force law).

See also electromagnetism, magnetism, electromagnetic field, electric field, Maxwell's equations