File:Mandelbrot numpy set 7.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(2,560 × 960 pixels, file size: 700 KB, MIME type: image/png)

Captions

Captions

Computing the Mandelbrot set with NumPy and complex matrices (Part 7)

Summary[edit]

Description
Deutsch: Die Mandelbrot-Menge wird mit NumPy unter Verwendung komplexer Matrizen berechnet. Die Einfärbung geschieht durch sogenannten Mandelbrot-Schaum, siehe die Galerie auf persianney.com.
English: The Mandelbrot set is calculated with NumPy using complex matrices. The coloring is done using so-called Mandelbrot foam, see the gallery on persianney.com.
Date
Source Own work
Author Majow
Other versions
PNG development
InfoField
 
This plot was created with Matplotlib.
Source code
InfoField

Python code

import numpy as np
import matplotlib.pyplot as plt

d, h = 800, 600  # pixel density (= image width) and image height
n, r = 200, 500  # number of iterations and escape radius (r > 2)

x = np.linspace(0, 2, num=d+1)
y = np.linspace(0, 2 * h / d, num=h+1)

A, B = np.meshgrid(x - 1, y - h / d)
C = (2.0 + 1.0j) * (A + B * 1j) - 0.5

Z = np.copy(C)
T = np.zeros(C.shape)

W = 0.05 * Z * 1j

for k in range(n):
    M = (abs(Z) > 0) & (abs(Z) < r)
    T[M] = T[M] + 1
    W[M] = (- 0.5) * W[M] / Z[M]
    Z[M] = Z[M] ** 2 + W[M] ** 2 + C[M]

fig = plt.figure(figsize=(12.8, 4.8))
fig.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)

ax1 = fig.add_subplot(1, 2, 1)
ax1.imshow(T ** 0.5, cmap=plt.cm.turbo, origin="lower")

ax2 = fig.add_subplot(1, 2, 2)
ax2.imshow(T ** 0.5, cmap=plt.cm.turbo_r, origin="lower")

fig.savefig("Mandelbrot_numpy_set_7.png", dpi=200)

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current10:08, 17 November 2023Thumbnail for version as of 10:08, 17 November 20232,560 × 960 (700 KB)Majow (talk | contribs)Uploaded own work with UploadWizard

Metadata