Earth and Mars follow real elliptical orbits, quickening near the Sun and easing away from it. From first principles of watching the planets in the night sky Mars appears to move westward in a predictable way - retrograde motion. In a elliptical heliocentric model this is easy to see why - the different orbits cause the planets to 'catch up' to one another or move further apart faster. Panel 3 shows the observed position of Mars on the horizon for an observer on earth (of course Mars wouldn't always be visible) showing its backward motion and how the Kepler and Ptolemaic models differed in their explanation of the phenomena. The first models of the solar system relied entirely on the geometric tools of Antiquity - compass, straight-edge etc. but a model built from perfect circles around Earth is insufficient to describe planetary motion, it is obviously too inaccurate and was improved upon by ancient astronomers like Ptolemy. The genius of Ptolemy's (and others) model was using the concept of an equant (bias against the true center - Earth) one of the most elegant ideas in the history of astronomy. Toggle it on and off to see just how much it achieved.
In panel I the Sun sits slightly off-centre, at a focus of each ellipse, and both planets visibly quicken near perihelion. Panel II rebuilds Mars's motion from circles, exactly as astronomers did for a millennium and a half: the deferent is drawn off-centre from Earth, and the planet keeps time not by the centre but by the equant, a companion point about which it sweeps equal angles in equal times. This "bisection of the eccentricity" is what lets the circles trace the real ellipse so faithfully. The hollow marker in panel III shows where the geometric model places Mars; the small gap to the true position is how closely it agrees with the modern orbit, held to a fraction of a degree, tens of arc-minutes at most, even for Mars with its stubbornly large eccentricity. A remarkable testament to how well the ancients had read the sky. Set the equant aside and that agreement loosens, revealing just how much work this one idea was doing.
Where Ptolemy and Kepler described the motion, Newton explained it.
Kepler had the shape of the orbit but not its cause. His ellipse and his equal-area rule were laws read straight off Tycho Brahe's observations, superb descriptions but not consequences of any deeper principle. Newton supplied the principle. Under universal gravitation every mass attracts every other along the line joining them with a force F = G Mmr2, a central pull falling off as the inverse square of the distance. And a spherically symmetric body such as the Sun attracts everything outside it exactly as if its whole mass sat at its centre (Newton's shell theorem). That is what licenses treating the Sun as a single point mass, and why the natural origin of the system is the Sun's centre, not the Earth.
From that one force law, Kepler's astronomy follows as theorems rather than fits. A central inverse-square attraction produces conic-section orbits, and the bound ones are ellipses with the force-centre at a focus: Kepler's first law, now derived. Because the force is central, angular momentum is conserved, so the radius vector sweeps equal areas in equal times: Kepler's second law, and the true meaning of what the equant had been approximating all along, since uniform rotation about the empty focus is very nearly uniform sweeping of area. Balancing gravity against the orbital acceleration gives T2 = 4π2GMa3, Kepler's third law, its constant now fixed by the Sun's mass.
Strictly, the Sun is not quite still: both bodies orbit their common centre of mass, but because the Sun so vastly outweighs the planets, that point sits barely outside its surface, so a Sun-fixed ellipse is excellent if not perfect. Restore the mutual tugs between planets and the orbit no longer closes exactly. It was this Newtonian frame of point masses, inverse-square gravity, and perturbations pushed to ever higher order that carried planetary prediction from the arc-minutes of the equant to the arc-seconds that would later betray the position of Neptune and the anomalous precession of Mercury's perihelion. Each stage kept what worked in the last and explained why it had. See it happen for yourself just below.
Nothing here is prescribed: the planet is released with a velocity and then simply pushed by gravity, integrated step by step under an inverse-square pull toward the Sun (a symplectic scheme, so energy is conserved and the shape is honest). With no companion it retraces the same ellipse forever; the closed orbit is a theorem of the force law, not an input. Raise the companion mass and that exactness breaks: a second source of gravity slowly rotates the long axis of the orbit, tracing a rosette that never quite closes. That drifting apsidal line (dashed) is precisely the planet–planet perturbation Newtonian astronomy spent centuries computing.
Every term used above, in one place.