the way the original mathematicians figured all this out absolutely melts my brain

no computers, no calculators, barely working telescopes looking at the moons orbiting Jupiter

(don't be limited by episode title, lots of amazing astrophysics in there)

* https://www.youtube.com/watch?v=8yhk1EZq9tY

The equations required to calculate perturbations, and the effort required to do it by hand with just paper, really are brain melting.

https://descanso.jpl.nasa.gov/monograph/series2/Descanso2_S0...

Basically pages and pages of differential equations, either modelled analytically or approximated (as accurately as possible) with Chebyshev polynomials.

Aside from the basic Kepler orbits, everything influences everything else. This doesn't make much of a different in the short term, but space is biiiiig and it doesn't take much for tiny influences to have a measurable effect.

There's a slightly simpler introduction to detailed perturbative planetary orbit calculations in Feynman's Lectures on Physics.

FWIW the solar system isn't unconditionally stable. Even without wandering visitors, there's a small chance Mercury might drift outwards and collide with one of the other Inners in the next few billion years.