In the Hipparchian and Ptolemaic systems of astronomy, the epicycle (from Ancient Greek: ἐπίκυκλος, literally on the circle, meaning circle moving on another circle) was a geometric model used to explain the variations in speed and direction of the apparent motion of the Moon, Sun, and planets. In particular it explained the apparent retrograde motion of the five planets known at the time. Secondarily, it also explained changes in the apparent distances of the planets from Earth.
It was first proposed by Apollonius of Perga at the end of the 3rd century BC. It was developed by Apollonius of Perga and Hipparchus of Rhodes, who used it extensively, during the second century BC, then formalized and extensively used by Ptolemy of Thebaid in his 2nd-century AD astronomical treatise the Almagest.
Epicyclical motion is used in the Antikythera Mechanism, an ancient Greek astronomical device for compensating for the elliptical orbit of the Moon, moving faster at perigee and slower at apogee than circular orbits would, using four gears, two of them engaged in an eccentric way that quite closely approximates Kepler's second law.