title: Why does using delta time in physics computations produce slower code than expected?
body: <p>I have a simple projectile motion simulation built using Pygame. I limited the FPS to 60 and calculated the delta time for each frame. I then use this delta time to update the position of my projectile. However, the problem is, the update seems to be very slow.</p>
  
  <p>Based on my paper computations for a given projectile trajectory, the projectile should complete its path in a little less than 5 seconds. However, much more time has elapsed before the projectile completes its path. Here is my code:</p>
  
  <pre><code>def update(self, dt):
      if not self.is_on_ground:
          self.time += dt # time is initialized to 0
  
          # calculate initial x and y velocities
          vx = self.vi * math.cos(self.angle)
          vy = self.vi * math.sin(self.angle)
  
          # kinematics
          self.dx = (vx * self.time)
          self.dy = (vy * self.time) + ((-9.8 * (self.time ** 2)) / 2)
  
          # update old positional values
          self.x = self.dx + self.init_x
          self.y = self.init_y - self.dy
  
          # update rectangle position
          self.rect.center = (self.x, self.y)
  
          # check if the ball has hit the ground
          self.check_collisions()
  </code></pre>
  
  <p>I would expect that the ball would hit the ground at the same time as the calculated time, however, it doesn't. I have ruled out the possibility that it is an FPS issue since printing <code>dt</code> always gives me a consistent 0.017 seconds (approximately 1/60). Am I missing something?</p>
  
  <p>Here is a sample run:</p>
  
  <pre><code>t       x       y       vi      angle
  0.5     687.51  751.21  21.93   1.15
  t       x       y       vi      angle
  1.0     692.02  744.88  21.93   1.15
  t       x       y       vi      angle
  1.51    696.63  740.95  21.93   1.15
  t       x       y       vi      angle
  2.02    701.14  739.59  21.93   1.15
  t       x       y       vi      angle
  2.53    705.78  740.77  21.93   1.15
  t       x       y       vi      angle
  3.04    710.38  744.5   21.93   1.15
  t       x       y       vi      angle
  3.55    715.0   750.83  21.93   1.15
  t       x       y       vi      angle
  4.07    719.62  759.75  21.93   1.15
  </code></pre>
  
  <p>Note - Lower y values means "physically" higher</p>
  
  <p>Using the equations <code>v_yf = v_yi + gt^2</code> and solving for <code>t</code> would give a time of approximately 2 seconds. Based on the results, the program takes twice as long to accomplish this.</p>
  
  <p>EDIT: Added Logs</p>