Derivation of the magnetic Euler–Heisenberg energy