Problem
Coursework required implementing numerical methods from scratch and comparing their accuracy, stability, and performance on real physics problems (ODEs/PDEs, chaos, Monte Carlo). Raw theory alone didn’t reveal which methods or parameter choices worked best in practice.
Solution
Built a reproducible set of notebooks and utilities that implement each method step-by-step, run controlled experiments, visualize errors and stability regimes, and benchmark run time. Each notebook includes derivations, code, plots, and a short conclusion so results are comparable across problems.
What I Did
-
ODE solvers (harmonic/anharmonic, driven/chaotic)
Implemented explicit Euler, semi-implicit (symplectic) Euler, RK2/Heun, and RK4. Verified convergence by fitting the error model for RK4. Checked energy drift on Hamiltonian systems, showing symplectic Euler better preserves (H(q,p)) over long horizons. -
Chaos & bifurcations
Generated the logistic-map bifurcation diagram and estimated the Lyapunov exponent. Integrated the Lorenz system:and visualized the strange attractor + return maps.
-
Finite differences (PDE/eigenproblems)
Discretized the 1D time-independent Schrödinger equationwith 2nd-order central differences, forming a tri-diagonal system solved efficiently. For an infinite well of width, verified equation and node counts of eigenfunctions.
-
Spectral/FFT tools
Used FFTs to analyze frequency content, compare spectral vs. FD resolution at equal grid sizes, and sanity-check Parseval-style energy consistency in time series. -
Monte Carlo
Implemented MC integration with importance sampling; confirmed error scaling on log–log plots and observed variance reductions on suitable test integrands. -
Performance & correctness
Vectorized inner loops with NumPy; profiled hotspots. Added lightweight checks (convergence orders, conservation laws) to prevent regressions. -
Visualization & reporting
Reusable Matplotlib helpers (phase portraits, bifurcations, error curves). Each notebook ends with Takeaways summarizing stable parameter ranges and method trade-offs.
Methods & Experiments (Examples)
-
Pendulum / Mass–Spring (ODE)
Small-angle model: .
Nonlinear pendulum:Step-size sweep : measured error vs. analytic solution; compared long-time energy behavior (RK4 baseline vs. symplectic Euler).
-
Lorenz Attractor (Chaos)
Parameters . RK4 with adaptive-step trials; separation of nearby trajectories to visualize sensitivity; Poincaré/return maps. -
Schrödinger (FD eigenproblem)
Infinite well and finite barrier; verified second-order convergence by halving and observing error reduction. -
Monte Carlo Integration
Estimated and multi-D integrals; compared plain vs. importance sampling; confirmed .
Results (Quick Snapshots)
- RK4 achieved ; symplectic Euler showed qualitatively superior long-time energy behavior.
- FD eigenvalues matched analytics to at moderate grids; errors halved when halved (2nd order).
- MC variance improved under importance sampling on selected integrands.
Additional Images (Gallery)
Logistic-map bifurcation diagram (period-doubling route to chaos).
Lorenz attractor integrated with RK4; color encodes state particle around a electromagnetised charged line.
First few eigenstates for a 1D infinite square well (FD discretization).