Can't get the correct error rate for RK4

Hi,

I'm doing numerical integration using Euler and Rk4. For Euler I get the expected first order error, but for the RK4 I can't get the 4th order error that I'm expecting.

Here are my RK4 method:

/*---------------------------------------------*/

Vector3 NumericalIntegration::rk4_step(Vector3 x, Vector3 dx, float dt){

Vector3 k1,k2,k3,k4;

k1 = dt * dx;

k2 = dt * (dx + k1/2.0f);

k3 = dt * (dx + k2/2.0f);

k4 = dt * (dx + k3);

return x + (k1+2.0f*k2+2.0f*k3+k4)/6.0f;

}

At each step I update my current position and velocity (in that order) using either Euler or RK4:

x = F(x,v,dt);

v = F(v,f/m,dt);

F is either Rk4.

I run the simulation for t=n seconds and the difference between the numerical solution and the exact solution at t=n is my error.

To find my error rate, I run the simulation for different values of dt (h or delta t). Each time I reduce the size of the dt or h by two. When I plot the error with respect to dt, I see that the error is of order 1 (reduced by the same factor of 2 as dt). The rate of reduction in error should be 4 and not 1. What am I doing wrong?

http://i51.tinypic.com/21e5fmd.png

http://i55.tinypic.com/2z3v12o.png