Status: stub — scaffold cells only; expand before relying on this notebook for a course offering.
Integrate a damped oscillator with scipy.integrate.solve_ivp.
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
def rhs(t, z, zeta=0.2, w0=2.0):
x, v = z
return [v, -2 * zeta * w0 * v - w0**2 * x]
sol = solve_ivp(rhs, (0, 10), [1.0, 0.0], max_step=1e-2)
plt.plot(sol.t, sol.y[0])
plt.xlabel('t')
plt.ylabel('x')
plt.grid(True, alpha=0.3)
plt.show()