I've been working for a couple of years on a computer algebra system written in Clojure (named "Emmy") designed for writing this like. It's a port of Gerald Sussman's scmutils library, plugged in to a bunch of modern graphics libraries.
Here are a few examples, shamefully lacking exposition since much of this is JUST working and I was powering through demos for a talk:
- particle in a quartic potential well: https://sritchie.github.io/clojure-conj-2023/notebooks/conj/...
- Phase Portrait of the Pendulum: https://sritchie.github.io/clojure-conj-2023/notebooks/conj/...
- Colin's torus geodesics: https://sritchie.github.io/clojure-conj-2023/notebooks/conj/...
- Taylor Series https://sritchie.github.io/clojure-conj-2023/notebooks/conj/...
- (p, q) torus knot: https://sritchie.github.io/clojure-conj-2023/notebooks/conj/...
- Dual Number Visualization: https://sritchie.github.io/clojure-conj-2023/notebooks/conj/...
I'd love a textbook like the one you link above with figures that feel almost like Kerbal games, powered by the real code in the book that is ALSO generating the math you see.
See https://github.com/mentat-collective/emmy for more information if this is interesting.