Runge-Kutta

Ordinary equations relate one quantity to another, for example:

    distance around circle = pi * diameter of circle

Differential equations relate quantities and changes to quantities to one another. Many physical systems can be modeled with differential equations. "Fourth-order Runge-Kutta" is a technique for solving differential equations approximately. So if you can describe a physical system with a differential equation, this module will let you simulate the behavior of that system over time.

Here is a pendulum. The state of the pendulum is described by two variables, the angle of the pendulum and the angular velocity. To model the system, we have to describe how these two quantities change over time:

    change in angular position = angular velocity
    change in angular velocity = - G / L sin(angular position)

Here, G is the acceleration due to gravity, and L is the length of the pendulum. This system is simulated below.

time
angular position
angular velocity

And here is a small solar system with planets moving according to Newtonian physics.

Code