# Is this correct second order approximation?

Tags:
1. Mar 13, 2015

### Alexandre

I have a second order differential equation of the form (theta is a function of time):
$\theta ''=F\left(\theta ,\theta '\right)$

Turning them to two first order equations I get:
$\begin{cases} \theta '\:=\omega \\ \omega '=F\left(\theta ,\omega \right) \end{cases}$

And here's the algorithm which I need to know whether it's correct or not:
It does give me a solution that is really close to first order approximation but the thing is, when I look at the phase space, first order approximation conserves energy better because curves are closer to being closed (the equation is non dissipative), so I'm wondering why is that. Second order approximation is supposed to be better.

2. Mar 13, 2015

### timthereaper

Is this Heun's method? I think it would go something like this given $\theta_0,\,\omega_0$:

$$\theta' = \omega = F_1(t,\theta) \\ \theta'' = \omega ' = F_2(t,\theta,\theta') \\ \\ k_1 = \theta_i + \Delta t F_1(t_i,\theta_1) \\ \theta_{i+1} = \theta_i + \frac{\Delta t}{2} \left [ F_1(t_i,\theta_i) + F_1(t_{i+1},k_1) \right ] \\ j_1 = \omega_i + \Delta t F_2(t_i,\theta_i,\omega_i) \\ \omega_{i+1} = \omega_i + \frac{\Delta t}{2} \left [ F_2(t_i,\theta_i,\omega_i) + F_2(t_{i+1}, \theta_{i+1}, j_1) \right ]$$

3. Mar 13, 2015

### Alexandre

Yes it's Heun's method, a.k.a. two stage Runge–Kutta method. In my case F is time independent.

I don't seem to understand what F1 and F2 are in your algorithm.