I try to get numerical solution of ordinary harmonic oscillator with symplectic integrator. The problem is that what I obtain doesn't conserve energy (but symplectic integration should do).
I consider 2 simplectic integrators - symplectic Euler method and symplectic 4th order method.
The equations of motion are:
$$ \dot{p} = -q \\ \dot{q} = p $$
So for Euler method we have formulas:
$$q_{n+1} = q_n + \Delta t \ p_n \\ p_{n+1} = p_n - \Delta t \ q_{n+1} $$
For 4th order symplectic method one has sequence of intermediate points: $$ p_{n+1/4} = p_n - \frac{2}{2 (2-2^{1/3})} \Delta t \ q_n \\ q_{n+1/4} = q_n + \frac{1}{2 (2-2^{1/3})} \Delta t \ p_{n+1/4} \\ \\ p_{n+2/4} = p_{n+1/4} + \frac{2^{1/3}}{2 - 2^{1/3}} \Delta t \ q_{n+1/4} \\ q_{n+2/4} = q_{n+1/4} + \frac{1-2^{1/3}}{2 (2-2^{1/3})} \Delta t \ p_{n+2/4} \\ \\ p_{n+3/4} = p_{n+2/4} - \frac{2}{2 (2-2^{1/3})} \Delta t \ q_{n+2/4} \\ q_{n+3/4} = q_{n+2/4} + \frac{1-2^{1/3}}{2 (2-2^{1/3})} \Delta t \ p_{n+3/4} \\ \\ p_{n+1} = p_{n+3/4} \\ q_{n+1} = q_{n+3/4} + \frac{1}{2 (2-2^{1/3})} \Delta t \ p_{n+1} $$
But both methods (Euler and 4th order) does not conserve energy. I choose initial conditions as $$ q_0 = 1.2 \ , \ \ p_0 = 0 $$
But what I have with both methods is not oscillations with conserved amplitude - it's oscillations with growing and growing (sufficiently fast) amplitude.
So, what might be a problem?