In the answer https://robotics.stackexchange.com/a/7512/22953 there is an example for trapetzoid trajectory planning that results in the following table.
\begin{array} {|r|r|} \hline time & t & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \hline acceleration& a & 0 & 2 & 2 & 2 & 0 & 0 & 0 & -2 & -2 & -2\\ velocity & v & 0 & 2 & 4 & 6 & 6 & 6 & 6 & 4 & 2 & 0\\ position & d & 0 & 1 & 4 & 9 & 15 & 21 & 27 & 32 & 35 & 36\\ \hline \end{array}
By ocular inspection it seems that
v[t] = v[t - 1] + a[t]
d[t] = d[t - 1] + (v[t - 1] + v[t]) / 2
What is the mathematical basis for this? Why is the average velocity used but not the average accelation? What would the corresponding table look like for a third degree trajectory (i.e. constant jerk instead of constant acceleration)?