;; Constants. width = 30 height = 30 size_pow_two = 16 size = 4 max_iteration = 100 ; How god the algorithm is for x_pos do width times for y_pos do height times is_inside_mandelbrot = 1 x = 0 ; x_math y = 0 ; y_math for i do max_iteration times ;; because the set is so small we need to scale evrything up with scale. ;; if x^2 + y^2 > 2^2 * size^2 then outside set. if x * x + y * y > 4 * size_pow_two then is_inside_mandelbrot = 0 else ;; z = z^2 + c ;; z = x + yi ;; c = x_pos + i*y_pos ;; z^2 = (x + yi)(x + yi) = x^2 -y^2 + 2yxi ;; therefore: x = x^2 - y^2 + x_pos, y = 2xy + y_pos x = x*x - y *y + x_pos * size y = 2 * x * y +y_pos * size end end if is_inside_mandelbrot == 1 then draw_pixel(x_pos,y_pos) end end