8.4b ODE algorithm labs
Source: Lab ideas from Computational Physics (Landau, Páez, Bordeianu), §8.4. Original drills with float-locked answers. Continues 8.4 ODE algorithms.
Explorer
Pure Python (math OK). No NumPy / VPython. Stubs fail until filled.
Shared oscillator. , so , . IC , . Analytic amplitude . Force . Energy .
Formula refresh
Warm up: pick the matching equation among lookalikes (same walk as the theory lesson).
Labs
Activity: Euler one step
Take one Euler step with from . Print x v with 10 decimals.
No input.
Write-ups
Using “Euler”, “tangent”, and “local”, explain:
In one sentence, why does a single Euler step from (0,1) leave v unchanged for F=−kx?
Minimum 3 words. Your answer must include: “Euler”, “tangent”, “local”.
0 words
Meet the writing requirements, then you can open the model answer.
Explorers
# harmonic_rk_compare_sketch.py — original structure (no VPython)
import math
def rk2_step(x, v, h, k, m=1.0):
def f(x, v):
return v, -k * x / m
f0, f1 = f(x, v)
k1x, k1v = h * f0, h * f1
f0, f1 = f(x + 0.5 * k1x, v + 0.5 * k1v)
return x + h * f0, v + h * f1 # equivalent to y+k2
# Compare x(0.25) from Euler / RK2 / RK4 vs A*sin(ω*0.25)