5.5.2. Exercise: Trigonometry 2#
When we walk on an inclined treadmill as in Fig. 5.7, we must overcome a backward force that is equal to:
\[
F = m g \sin \theta
\]
where \(m\) is the person’s mass, \(g\) is 9.81 m/s² and \(\theta\) is the treadmill angle. Write a function named plot_force
that takes the mass as an argument and that plots \(F\) for \(\theta \in [-20, 20]\) degrees. Then, test your function for \(m = 65\) kg.

Fig. 5.7 Walking on an inclined surface.#
Show code cell content
import numpy as np
import matplotlib.pyplot as plt
def plot_force(m: float) -> None:
"""
Plot the force a person needs to overcome on an inclined treadmill.
Parameters
----------
m :
Mass of the person in kilograms.
Returns
-------
None
"""
# First, define an angle array
theta = np.linspace(-30, 30, 100, endpoint=False)
# Calculate the force
force = m * 9.81 * np.sin(np.deg2rad(theta))
# Plot it
plt.plot(theta, force)
plt.xlabel("Angle (deg)")
plt.ylabel("Force (N)")
plt.show()
# Test the function
plot_force(65)
