Doing Homework¶
The Jupyter Notebook is a good environment for working on your Physics homework (or Statics or Dynamics homework).
Having a tool like this is even more helpful when your problems become more complicated, which is certain to happen in a science or engineering career.
Workflow¶
Make a folder for your class on your computer
(or on OneDrive
if you're using the College computers).
For each homework set, start a new Jupyter Notebook in that folder with a
name such as HW10.
For each problem, take a screenshot to display. Solve the problem on paper using symbols rather than numbers (see Symbolic Problem Solving). Scan or photograph your written work to link in the Notebook. Use your symbolic solution to write the final equations in Python to obtain a numerical result.
By the end of the semester, you'll have a great resource you can use for review or future re-use.
Advantages¶
Here are a few reasons to make the extra effort to use a coding environment.
- If you make a mistake, it's easy to tweak then re-run the calculations. It's also easy to find the solution for different input parameters.
- You can share your work and results with other students or with the instructor if you have questions.
- You can save your work for later review or re-use.
- You don't have to worry about keeping significant digits. The computer maintains a very high precision.
- You can explore interesting ideas further. Make a graph, or explore alternate scenarios. This is the way to master the ideas you learn in class.
- You may be able to use advanced Python libraries like SciPy and NumPy to help find the solution.
- You will get better at coding, which is a valuable skill. The Jupyter Notebook is a powerful and widely used method for sharing technical information. You will be ready when you're not just solving homework problems, but working with a team on a complex project.
from numpy import *
theta = 40*pi/180 # angle in radians
h = 2 # height in m
mu = 0.8 # friction coefficient
g = 9.8 # m/s²
v = sqrt( 2*g*h*(1- mu/tan(theta)) )
print('v = ',v,' m/s')
v = 1.3515203795154433 m/s
That's the answer, but I wonder what the graph of final speed vs ramp angle looks like.
import matplotlib.pyplot as plt
th = linspace(2,89)
v = sqrt( 2*g*h*(1- mu/tan(th*pi/180)) )
plt.plot( th, v )
plt.grid()
plt.xlabel('ramp angle, degrees')
plt.ylabel('final speed, m/s');
/tmp/ipykernel_9647/290915728.py:3: RuntimeWarning: invalid value encountered in sqrt v = sqrt( 2*g*h*(1- mu/tan(th*pi/180)) )
The invalid value warning is due to the failure of the equation
when $\theta \lt 38.7^\circ = \tan^{-1} \mu$.
Then we have the square-root of a negative value.