  We derive in full generality the equations that govern the time dependence of
the energy ${\mathcal E}$ of the decay electrons in a muon $g-2$ experiment. We
include both electromagnetic and gravitational effects and we estimate possible
systematics on the measurements of $g-2\equiv 2(1+a)$, whose experimental
uncertainty will soon reach $\Delta a/a\approx 10^{-7}$. In addition to the
standard modulation of ${\mathcal E}$ when the motion is orthogonal to a
constant magnetic field $B$, with angular frequency $\omega_a=e a |B|/m$, we
study effects due to: (1) a non constant muon $\gamma$ factor, in presence of
electric fields $E$, (2) a correction due to a component of the muon velocity
along $B$ (the `pitch correction'), (3) corrections to the precession rate due
to $E$ fields, (4) non-trivial spacetime metrics. Oscillations along the radial
and vertical directions of the muon lead to oscillations in ${\mathcal E}$ with
a relative size of order $10^{-6}$, for the BNL $g-2$ experiment. We then find
a subleading effect in the `pitch' correction, leading to a frequency shift of
$\Delta \omega_a/\omega_a \approx {\cal O}(10^{-9})$ and subleading effects of
about $\Delta \omega_a/\omega_a \approx {\rm few} \times {\cal
O}(10^{-8}-10^{-9})$ due to $E$ fields. Finally we show that GR effects are
dominated by the Coriolis force, due to the Earth rotation with angular
frequency $\omega_T$, leading to a correction of about $\Delta
\omega_a/\omega_a \approx \omega_T/(\gamma \omega_a) \approx {\cal
O}(10^{-12})$. A similar correction might be more appreciable for future
electron $g-2$ experiments, being of order $\Delta \omega_a/\omega_{a, {\rm
el}} \approx \omega_T/(\omega_{a, {\rm el}}) \approx 7\times 10^{-13}$,
compared to the present experimental uncertainty, $\Delta a_{\rm el}/a_{\rm
el}\approx 10^{-10}$, and forecasted to reach soon $\Delta a_{\rm el}/a_{\rm
el}\approx 10^{-11}$.
