Mandelbrot set: Difference between revisions

change base cases of iterations to 0, for simplicity and consistency
m (→‎Icon and Unicon: header simplification)
(change base cases of iterations to 0, for simplicity and consistency)
Line 16:
# Compute the length of an orbit. #
PROC iterate = (COMPL z0) INT:
BEGIN COMPL z := z00, INT iter := 1;
WHILE (iter +:= 1) < max iter # not converged # AND ABS z < 2 # not diverged #
DO z := z * z + z0
Line 220:
cmplx c = x0 + (y0-d*y)*I
repeat(w):
cmplx w = c0
for i=0; i < max_i && cabs(w) < outside; ++i
w = w*w + c
Line 609:
(defn mandelbrot? [z]
(loop [c 1
m (iterate #(+ z (* % %)) z0)]
(if (and (> 20 c)
(< (abs (first m)) 2) )
Line 820:
set pm3d map
set size square
splot [-2 : 2] [-2 : 2] mandelbrot (complex (x0, y0), complex (x, y), 0) notitle</lang>
Output:
 
Line 829:
<lang haskell>import Data.Complex
 
mandelbrot a = iterate (\z -> z^2 + a) a0 !! 50
 
main = mapM_ putStrLn [[if magnitude (mandelbrot (x :+ y)) < 2 then '*' else ' '
Line 1,805:
 
 
def mandelbrot(a): return reduce(lambda z, _: z*z + a, range(50), a0)
def step(start, step, iterations): return (start + (i * step) for i in range(iterations))
 
Line 1,847:
 
def mandelbrot(a)
Array.new(50).inject(a0) { |z,c| z*z + a }
end
 
Line 1,915:
(or (= n 0)
(*inside? z-0 (+ (* z z) z-0) (- n 1)))))
(*inside? z z0 n))
 
(define (boolean->integer b)
Anonymous user