Skip to content

examples: Mandelbrot / Julia escape-time on the ANE #174

Description

@sbryngelson

An eye-catching, self-contained demo: the Mandelbrot (and/or a Julia) set by escape-time iteration on the engine, in the family of examples/fluid_vorticity.py / examples/reaction_diffusion.py.

Approach:

  • Build a coordinate grid of c = cr + i*ci over the complex plane. Complex numbers are carried as two real tensors zr, zi (the ANE is real-valued; aneforge/fft.py already carries spectra this way).
  • One iteration is elementwise: zr, zi = zr*zr - zi*zi + cr, 2*zr*zi + ci, then an escape mask where zr*zr + zi*zi > 4. Accumulate the escape iteration count with select / maximum (in graph.py). Each iteration is one on-engine forward pass over the whole grid.
  • After the fixed iteration budget, map the smooth iteration count through a colormap and save a PNG (PIL, like the sibling demos). Optionally sweep a Julia c to make a short animation.

Deliverable: examples/mandelbrot.py (one file, docstring), plus an examples/README.md entry.

Testing: spot-check a handful of grid points against a plain numpy escape-time reference. Requires any Apple Silicon Mac. Follow reaction_diffusion.py for the render, _common.py for setup.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions