Introduction to Computer Programming for the Physical Sciences
Timothy Brandt
Fall 2021
Homework 5
1. We have looked at a few functions in this class. One important one for physics is the Maxwell-Boltzmann
distribution 3/2
mv 2
m
p(v) = 4πv 2 exp − . (1)
2πkB T 2kB T
Please plot the Maxwell-Boltzmann distribution p(v) for nitrogen gas (molecular mass 4.65 × 10−26 kg) and
helium gas (atomic mass 6.65×10−27 kg), both at a temperature of 300 K. Please choosep appropriate units and
labels for both axes. Finally, the Maxwell-Boltzmann distribution peaks at v0 = 2kB T /m. Please plot a
single point at (v0 , p(v0 )) on top of the continuous Maxwell-Boltzmann distribution for both chemical species.
2. I have supplied sample data in the file [Link], with time in the first column and signal in the
second column. Please plot these as points, and plot the model y = x − cos x on the same axes. Please
include a legend and axis labels.
3. In a previous homework, I stated (without proof) that the solution to a lightly damped harmonic oscillator
is
x(t) = Ae−(γ/2)t cos (ωt + φ) (2)
where x is the position, γ describes how strong the damping is, ω is the angular frequency (shifted from the
frequency ω0 of the undamped oscillator) by
ω 2 = ω02 − γ 2 /4, (3)
A is the amplitude, and φ is a phase.
a. Modify the function that you wrote for x in a previous homework to make it a function of t, A, γ, ω0 ,
and φ. In other words, you’ll have to just slightly change your earlier function to take ω0 rather than ω as
an argument.
b. Assume A = 1 m, ω0 = 1 rad s−1 , and φ = 0. Plot (and label) the motion of the oscillator between t = 0
and t = 20 seconds for γ = 0.1, 0.2, 0.5, and 1 s−1 , all on the same plot.
c. Now assume A = 1 m, ω0 = 1 rad s−1 , φ = 0, and γ = 0.2 s−1 . Please plot x(t) and also the envelope
defined by the two functions
X(t) = ±e−(γ/2)t . (4)
Please use thinner lines in a different color (say, gray) for the envelope; you may also make the lines dashed
or dotted. Please try to make the figure look nice, like you would see in a textbook.