I am attending a Pixar class at the Khan Academy and encountering a simulation of a double spring at a certain time step. I understand how it works and why it behaves that way, but I want to know if the math is actually correct. What interests me are the following lines:

```
// mass 1 speed
mass1VelocityY = mass1VelocityY + mass1AccelerationY * timeStep;
mass1VelocityX = mass1VelocityX + mass1AccelerationX * timeStep;
// ground 1 position
mass1PositionY = mass1PositionY + mass1VelocityY * timeStep;
mass1PositionX = mass1PositionX + mass1VelocityX * timeStep;
```

So we first calculate the speed and add a fraction of the calculated acceleration to it. Then we calculate the position and add a fraction of the calculated speed to it. So we build the final position in time `T`

by summing `T / time step`

Intermediate positions.

Given the formula for the shift `s = ut + 0.5at ^ 2`

from where:

s = displacement

u = initial speed

a = acceleration

t = time

If I use the values: s = 0, u = 0, a = 1, t = 2, I get `s = 2`

, This means that if I start from zero and build up the speed with an acceleration of 1 m / s / s, I will end up at position 2 with a speed of 2 m / s.

Now, if I try to follow the same logic, but split that result into 20 steps`(2 / 0.1 - t = 2 time step = 0.1)`

If you summarize the results of all these intermediate steps as in this code, I get another result: `s = 0.55 at t = 1`

and `s = 2.1 at t = 2`

,

My initial intuition is that, because in the code we multiply timeStep twice with the acceleration in the code, this leads to a potentiation and the progression is no longer linear and smaller steps get smaller values at the beginning. So I have 3 questions:

1) Did I understand what the code is doing right?

2) Is what the code does the most correct / accurate method of calculating the displacement?

3) I really want to understand these concepts. So if you have any other advice or know something that might be helpful to me, please let me know.