Electron magnetic dipole moment
In atomic physics, the magnetic dipole moment of an electron is caused by its intrinsic property of spin within a magnetic field.

# Explanation of magnetic moment
The electron is a negatively charged particle with angular momentum. A rotating electrically charged body in classical electrodynamics causes a magnetic dipole effect creating magnetic poles of equal magnitude but opposite polarity like a bar magnet.  For magnetic dipoles, the dipole moment points from the magnetic south to the magnetic north pole. The electron exists in a magnetic field which exerts a torque opposing its alignment creating a potential energy that depends on its orientation with respect to the field. The magnetic energy of an electron is approximately twice what it should be in classical mechanics. The factor of two multiplying the electron spin angular momentum comes from the fact that it is twice as effective in producing magnetic moment. This factor is called the electronic spin g-factor. The persistent early spectroscopists, such as Alfred Lande, worked out a way to calculate the effect of the various directions of angular momenta. The resulting geometric factor  is called the Lande g-factor.
The intrinsic magnetic moment  of a particle with charge q, mass m, and spin s, is
where the dimensionless quantity g is called the g-factor.
The g-factor is an essential value related to the magnetic moment of the subatomic particles and corrects for the precession of the angular momentum. One of the triumphs of the theory of quantum electrodynamics is its accurate prediction of the electron g-factor, which has been experimentally determined to have the value 2.002319... The value of 2 arises from the Dirac equation, a fundamental equation connecting the electron's spin with its electromagnetic properties, and the correction of 0.002319..., called the anomalous magnetic dipole moment of the electron, arises from the electron's interaction with virtual photons in quantum electrodynamics.  Reduction of the Dirac equation for an electron in a magnetic field to its non-relativistic limit yields the Schrodinger equation with a correction term which takes account of the interaction of the electron's intrinsic magnetic moment with the magnetic field giving the correct energy.
The total spin magnetic moment of the electron is
where g_s=2 in Dirac mechanics, but is slightly larger due to Quantum Electrodynamic effects, \mu_{B} is the Bohr magneton and s is the electron spin.  An electron has an intrinsic magnetic dipole moment of approximately one Bohr magneton.
The z component of the electron magnetic moment is
where ms is the spin quantum number.
It is important to notice that \boldsymbol{\mu} is a negative constant multiplied by the spin, so the magnetic moment is antiparallel to the spin angular momentum.

# Orbital magnetic dipole moment
Generally, for a hydrogen atomic electron in state 
\Psi_{n,l,m} where n, l and m are the 
principal, azimuthal and magnetic quantum numbers respectively, the total magnetic
dipole moment due to orbital angular momentum is given by
where \mu_{B} is the Bohr magneton.
The z-component of the orbital magnetic dipole moment for an electron with a magnetic quantum number ml is given by