Based on equations of motion in
this paper however this implementation is incorrect; when it is run then:
a) when the pendulum passes past the vertical upright position is does not accelerate downwards but instead starts to decelerate before reversing and going backwards
b) when it is left for some time to run it increases in speed (energy) over time.