A small scientific showpiece to sit alongside examples/heat_equation.py, examples/poisson_spectral.py, and examples/nbody.py: integrate the Lorenz attractor on the engine and plot the butterfly.
Approach:
- State is the 3-vector
(x, y, z); the Lorenz vector field dx=sigma*(y-x), dy=x*(rho-z)-y, dz=x*y-beta*z is a handful of elementwise ops.
- One RK4 step is a small graph (four field evaluations + the weighted combine). Roll out N steps, dispatching the step each iteration, collecting the trajectory host-side.
- Render the trajectory (e.g. x-z projection) to a PNG with matplotlib or PIL, matching how the other scientific demos save their figures.
Deliverable: examples/lorenz.py (one file, module docstring), plus an examples/README.md entry.
Testing: compare the first ~100 steps against a numpy RK4 reference (chaotic systems diverge later, so check the short-horizon trajectory, not the endpoint). Requires any Apple Silicon Mac. _common.py has the env/scaffolding; nbody.py is a good structural template for an on-engine integrator.
A small scientific showpiece to sit alongside
examples/heat_equation.py,examples/poisson_spectral.py, andexamples/nbody.py: integrate the Lorenz attractor on the engine and plot the butterfly.Approach:
(x, y, z); the Lorenz vector fielddx=sigma*(y-x),dy=x*(rho-z)-y,dz=x*y-beta*zis a handful of elementwise ops.Deliverable:
examples/lorenz.py(one file, module docstring), plus anexamples/README.mdentry.Testing: compare the first ~100 steps against a numpy RK4 reference (chaotic systems diverge later, so check the short-horizon trajectory, not the endpoint). Requires any Apple Silicon Mac.
_common.pyhas the env/scaffolding;nbody.pyis a good structural template for an on-engine integrator.