  Alkali-metal atomic magnetometers suffer from heading errors in geomagnetic
fields as the measured magnetic field depends on the orientation of the sensor
with respect to the field. In addition to the nonlinear Zeeman splitting, the
difference between Zeeman resonances in the two hyperfine ground states can
also generate heading errors depending on initial spin polarization. We examine
heading errors in an all-optical scalar magnetometer that uses free precession
of polarized $^{87}\text{Rb}$ atoms by varying the direction and magnitude of
the magnetic field at different spin polarization regimes. In the high
polarization limit where the lower hyperfine ground state $F = 1$ is almost
depopulated, we show that heading errors can be corrected with an analytical
expression, reducing the errors by two orders of magnitude in Earth's field. We
also verify the linearity of the measured Zeeman precession frequency with the
magnetic field. With lower spin polarization, we find that the splitting of the
Zeeman resonances for the two hyperfine states causes beating in the precession
signals and nonlinearity of the measured precession frequency with the magnetic
field. We correct for the frequency shifts by using the unique probe geometry
where two orthogonal probe beams measure opposite relative phases between the
two hyperfine states during the spin precession.
