And if you play with masses enough, it'll get stuck in a corner.
How to improve stability? What are pros and cons of Hamiltonian calculation versus Lagrangian? Is the translation smooth? What's funky about the denominator?
Otherwise, though I'm not a web developer, I think projects like this are generally split into multiple files for clarity rather than kept entirely in index.html, though this admittedly isn't my area. Comments count for a lot, and this code won't look as straight-forward to you in a couple of months. Try to put a spin on it. Zazz it up by at least adding Lissajous curves. Maybe rewrite it in C or Rust or something else that compiles into Web Assembly and runn it like that? I mean, good on you, but this is a very standard homework and otherwise a pretty run-of-the-mill Runge-Kutta project.