A physics simulation of the inverted pendulum problem