Consider the differential equation:

The Runge-Kutta 4th order algorithm uses intermediate points in an interval of duration h to calculate the state xk+1 from xk as follows:
Note that the number of calculations per time step is larger than that for Euler Method. However, this method is more accurate than Euler method (for the same time step) for most systems.
Can you program an algorithm which implements this method for the swing equations ? |