Vehicle acceleration What I'm essentially doing is Kalman Filter. If anyone is familiar with (but it doesn't really matter in this case). Consider the following formulas:
$$x_k=x_{k-1}+v_{k-1}dt+a_{k-1}\frac{dt^2}{2}$$
$$v_k=v_{k-1}+a_{k-1}dt$$
$$a_k=a_{k-1}$$
where $p$ is position, $v$ is velocity and $a$ is acceleration. The above model represents the movement of a vehicle... Why is acceleration taken into account, both in position and velocity? And why is it in position $\frac{dt^2}{2}$?
 A: As written down, your code describes a motion with constant acceleration (see $a_k=a_{k-1}$), so the trajectory will simply be a quadratic function (parabola).
Every moment $dt$, the velocity changes by the obvious amount, $dt\cdot a$. The same is true for position which changes by $dt\cdot v$ but there is an extra piece $a/2\cdot dt^2$ in the change of the position. This term is infinitely smaller than the main term, $dt\cdot v$, and if $dt$ is short enough, you may neglect it.
However, if you include it, you get a higher accuracy of the simulation even if $dt$ isn't too small. Why? Because the change of the position $p$ during the time $dt$ is calculated as $dt$ times the average velocity in this short time interval. And because the velocity is changing approximately linearly, the average velocity is
$$ \overline v = \frac{v(t)+v(t+dt)}{2} = \frac{v(t)+v(t)+a(t)dt}{2} = v(t)+\frac{a(t)dt}{2}  $$
If you multiply this $\overline v$ by $dt$, you get the change of the position $p$ as incorporated to your first equation.
