# [ODE] ODE BUG

Fri Oct 21 11:09:21 MST 2005

```You make a small mistake

To calculate the distance with a constant acceleration you can x = v*t + 0.5*a*t^2 to get the correct answer. So for you example the correct answer is 490,5 m.

ODE use a approximation and with more steps the error becomes smaller.
#step  distance  error
1      981 m     490.5 m
2      735.75 m  245,25 m
4      613.1 m   122.6 m
100    485.6 m   0.1 m

kalikali at tlen.pl wrote:

>My formula IS correct.
>
>Try to do simple experiment:
>
>Put some body in the field of grafity (9,81 m/s) at height 1000 m, v0 = 0
>Let's use this formula:
>
>x = v*t + a*t^2
>
>Assume 1 step, t = 10s, final distance is:
>
>x = 0*10 + 9,81*10^2  = 981 m
>
>//=================================================
>
>Do it again with 2 smaller 5 s steps:
>
>x = 0*5 + 9,81 * 5^2  = 245.25 m     (fianal velocity after this step is: v = v0 + a * t = 0 + 9.81 * 5 = 49.05 m/s)
>
>x = 49.05 * 5  + 9,81 * 5^2 = 490.5 m
>
>your final distance is: 245.25 + 490.5   = 735.75 m
>
>//==================================================
>
>
>Do it once again with 4 smaller 2.5 s steps:
>
>x = 0*2.5 + 9.81 * 2.5^2  = 61.3125 m	   (v = 24.525)
>
>x = 24.525 *2.5 + 9.81 * 2.5^2  = 122.625 m	   (v = 49.05)
>
>x = 49.05 *2.5 + 9.81 * 2.5^2  =  183.9375 m       (v = 73.575)
>
>x = 73.575 *2.5 + 9.81 * 2.5^2  =  245.25 m
>
>
>so your final distance is: 613.125 m
>
>//==================================================
>
>AS YOU CAN SEE with smaller timesteps error is BIGGER !!!!
>(by the way, final velocity is the same because velocity equation is correct)
>
>The correct formula is:
>
>x = v*t + 0.5*a*t^2
>
>//========================================================================
>
>What do You mean "only correct for constant acceleration" ???
>Acceleration is constant in one timestep.
>No matter how small the timestep is.
>
>_______________________________________________
>ODE mailing list
>ODE at q12.org
>http://q12.org/mailman/listinfo/ode
>
>
>
>

```