The sun rotates in an assumed circular orbit as seen from the earth. The coordinates of the sun's vector in this orbit are , where d = fraction of year elapsed since the winter solstice, i.e.

From our special frame, the orbit is tilted at angle which is about 23 degrees in the X-Z plane. So we apply a rotation transformation as shown below. In addition, our special frame of reference rotates also once per year but around the earth's axis so that another rotation transformation is needed. Thus may be calculated using two coordinate transformations

As a check, values at winter solstice (d = 0) and at spring equinox (d = 0.25), are

as expected. Explicitly solving for

Note that
so that
(the term responsible for the lag and advance of the sun) is small and
.
Thus
describes a figure of eight motion around the
vector moving mainly up and down by 23 degrees.