Skip to content

Varun-nair1997/Mandelbrot_Set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mandelbrot Set Visualization

Author: Varun Nair

This repository contains a Python implementation for visualizing the Mandelbrot set, adapted from the Rosetta Code reference implementation.

The program computes and displays a graphical representation of the Mandelbrot set using NumPy for numerical computation and Matplotlib for visualization.


Mathematical Formulation

The Mandelbrot set is defined through the iterative function:

zₖ₊₁ = zₖⁿ + c

where:

  • z and c are complex numbers
  • n is a positive integer (default: n = 2)
  • z₀ = 0

For each complex number c, the sequence is iterated up to a maximum number of iterations.

A point c belongs to the Mandelbrot set if the sequence remains bounded:

|zₖ| < 2 for all k

If |zₖ| ≥ 2, the sequence is said to escape to infinity.


Numerical Method

  1. Construct a 2D grid of complex numbers:

    • Real axis in [-2, 2]
    • Imaginary axis in [-2, 2]
  2. Initialize:

    • Z = 0
    • Track escape (exit) times for each point
  3. Iterate:

    • Z ← Zⁿ + C
    • Record iteration number when |Z| ≥ 2
  4. Visualize:

    • Escape times are mapped to colors
    • Displayed using Matplotlib colormap

Features

  • Adjustable resolution (npts)
  • Adjustable maximum iteration depth (max_iter)
  • Configurable exponent (n)
  • Vectorized NumPy implementation
  • Color-mapped escape-time visualization

Requirements

  • Python 3.8+
  • NumPy
  • Matplotlib

Install dependencies with: pip install numpy matplotlib


Usage

Run the script directly: python mandelbrot.py

Default execution: mandlebrot(1000, 130, 2)

Parameters

mandlebrot(npts=300, max_iter=100, n=2)

  • npts: Controls resolution (higher → more detail)
  • max_iter: Maximum number of iterations
  • n: Exponent in the iteration formula zⁿ + c

Output

  • A graphical window displaying the Mandelbrot set
  • Color intensity corresponds to escape time
  • Higher iteration depth reveals finer boundary structure

Limitations

  • Single-threaded CPU implementation
  • No zoom or interactive exploration
  • Memory usage increases with resolution
  • No image export functionality (display only)

About

Program to display a graphical representation of the mandelbrot set with given resolution parameters as input

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages