Mandelbrot set: Difference between revisions
m
→{{header|Python}}: Added a few comments.
(→{{header|Python}}: a more mathematical spelling, as the students are used to it.) |
m (→{{header|Python}}: Added a few comments.) |
||
Line 6,394:
import matplotlib.pyplot as plt
p = 100 # points per unit
n = 50 # number of iterations
r = 2.5 # escape radius (must be greater than 2)▼
x = np.linspace(-2.5, 1.5,
y = np.linspace(-1.5, 1.5,
A, B = np.meshgrid(x, y)
C = A + B
Z = np.zeros_like(C) # initial values are always zero
T = np.zeros(C.shape) # table of escape times
M = abs(Z) < r # mark all points that have not escaped
for k in range(n):
Z[M] = Z[M]
M = abs(Z) < r
T[M] = k + 1
|