Ordinary
Differential Equation

A
simple Harmonic Oscillator : Euler, Runge-Kutta and Numerov methods

A simple Harmonic Oscillator (as defined in Problem 6.2 of "The Nature of Mathematical Modeling") is studied with the Euler, Runge-Kutta and Numerov methods.

For each method, I verified :

- The minimum step size needed for the average error to be less than 0.001
- The final error
- The final slope
- The overall computation time (when higher than 1 ms)

Results for the Euler Method

Here is Euler's answer to the problem :

Results for the Runge-Kutta Method

Here is Runge-Kutta's answer to the problem :

Results for the Numerov Method

Here is another method also based on Taylor decomposition. This second order method is very efficient for second order differential equations like Harmonic oscillator. We actually get better results than with Fourth-order Runge-Kutta. Here is 2 close-up graphs of the method for a step size of 0.1and 0.6. In green is the cos function and in yellow the estimation.

Here is Numerov's answer to the problem :

Here is the C code :