The Runge-Kutta methods are a set of numerical methods for solving first order differential equations of the form,
They take the variable (y in the equation above) at a given time and use the known expression for the derivative of the variable to approximate the value of the variable a small interval of time, h, later in time. The simplest Runge-Kutta method is also known as the Euler method which is what the Example Problem used. It uses the following expression to approximate what y will be after the time interval h.
The Euler method is simple since it is only the first order Runge-Kutta, but it has poor accuracy. Much better accuracy can be obtained using the same step size, h, by using the following fourth order Runge-Kutta method. This fourth order Runge-Kutta method is probably the most commonly used Runge-Kutta method, as it it a good balance between accuracy and complexity.
This next method is a version of the fifth order Runge-Kutta method. (There are several different versions of the higher order methods.) It is more accurate than the fourth order Runge-Kutta method, although it is also more complex.
The trebuchet simulation uses the fifth order Runge-Kutta method to solve the Equations of Motion. It also uses the fourth order Runge-Kutta method to check the accuracy of the solution. Any numerical method only gives an approximation of the actual answer, and its accuracy is dependent on the step size, h. The way the simulation determines it is using a small enough step size is that it compares the answers of the fourth and fifth order methods to make sure the answers agree within a specified tolerance of each other. If the answers are very close then the answer is considered to be a reasonable approximation, but if they aren’t close, the time step is made smaller until the answers do agree within the tolerance.