Interactive simulations & visualizations

Visualizing the beauty in physics and mathematics


Project maintained by zhendrikse Hosted on GitHub Pages — Theme by mattgraham

Numerical methods


📌 Based on this code and accompanying video
📌 Refactored and ported to JavaScript by Zeger Hendrikse to numerical_methods.js
👉 Also refactored to numerical_methods.py

Comparison of accuracy of numerical methods:

Click to start the animation!

Numeric integrators and harmonic oscillators

📌 Semi-implicit (= symplectic) Euler $\Rightarrow$ symplectic $\Rightarrow$ energy stays bounded
📌 Verlet $\Rightarrow$ symplectic $\Rightarrow$ energy oscillates
📌 RK4 $\Rightarrow$ not symplectic $\Rightarrow$ energy grows slowly.

Corollary:

👉 Game engines use Verlet
👉 Physics engines use symplectic integrators
👉 RK4 is numerically more accurate per step, but performs worse for Hamiltonian systems in the long run.


Share on: