import numpy as np
import matplotlib.pyplot as plt
Run to view results
#Use this cell to calculate the velocity of a ball after falling 2 meters
initialHeight = 2 # meters
gravityAccMag = 9.81 #meters/s^2, magnitude of acceleration due to gravity
##### Begin Editing #####
finalVelocity = gravityAccMag * (initialHeight/gravityAccMag) # in meters/s. This should be a vector.
##### End Editing #####
velocityMagnitude = np.linalg.norm(finalVelocity) #numpy.linalg.norm takes the magnitude of an array
print('The final velocity of a ball after falling 2 meters has a magnitude of {} meters/second'.format(velocityMagnitude))
Run to view results
#Use this cell to calculate the magnitude of the drag force for a ball that has fallen 2 meters
vel = velocityMagnitude*np.array([1./np.sqrt(3),1./np.sqrt(6),1./np.sqrt(2)]) # meters/s
r = 0.025 # meters
##### Begin Editing #####
A = 3.14159 * r * r #m^2
C = 0.5 #unitless
rho = 1.225 #kg/m^3
dragForce = (-1/2) * C * A * rho * abs(vel) * vel
##### End Editing #####
dragMagnitude = np.linalg.norm(dragForce)
print('The magnitude of the air drag force is {}'.format(dragMagnitude))
Run to view results
#Run this cell without editing
print(np.linalg.norm(vel)*vel)
print(vel*vel)
Run to view results
#Use this cell to calculate the ratio of the magnitude of the drag force to gravity
##### Begin Editing #####
gravityForce = dragForce - 0.075 * 9.81
##### End Editing #####
gravityMagnitude = np.linalg.norm(gravityForce)
ratio = dragMagnitude / gravityMagnitude
print('The ratio of the air drag force to gravity is {}'.format(ratio))
Run to view results