Below we compute and plot velocity and height of the ball during its motion. This shows that the ball reaches the highest point of about 5 meters approximately one second after being thrown up. At that time ball velocity changes from positive to negative.
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import matplotlib.pyplot as plt
import numpy as np
def ball_height(t, v_0=10):
g = 9.81
return v_0*t - 0.5*g*t**2
def ball_velocity(t, v_0=10):
g = 9.81
return v_0 - g*t
print('{:>3} {:>5} {:>4}'.format('t', 'v', 'h'))
print('--- ----- ----')
for t in np.linspace(0,2, 11):
v = ball_velocity(t)
h = ball_height(t)
print('{:3.1f} {:>5.2f} {:4.2f}'.format(t, v, h))
t = np.linspace(0,2)
plt.figure(figsize=(4,2))
ax = plt.subplot(111)
plt.plot([1,1], [-10, 10], 'k:')
plt.plot(t, ball_velocity(t), 'r-', label='h')
plt.xlabel('time (sec)')
plt.ylabel('velocity (m/s)', color='r')
ax2 = ax.twinx()
plt.plot(t, ball_height(t), label='v')
plt.xlabel('time (sec)', fontsize=8)
plt.ylabel('height (meters)', color='b')
plt.title('Height and velocity vs time (v$_0$ = 10 m/s)', fontsize=10)
plt.show()