Skip to content

Instantly share code, notes, and snippets.

@abecus
Last active March 15, 2020 08:57
Show Gist options
  • Save abecus/32203f7613ae9d5af04cf5ec0653303b to your computer and use it in GitHub Desktop.
Save abecus/32203f7613ae9d5af04cf5ec0653303b to your computer and use it in GitHub Desktop.
use to find the divergence of complex number for mandelbrot set
import matplotlib.pyplot as plt
import numpy as np
def get_iter(c:complex, thresh:int =4, max_steps:int =25) -> int:
# Z_(n) = (Z_(n-1))^2 + c
# Z_(0) = c
z=c
i=1
while i<max_steps and (z*z.conjugate()).real<thresh:
z=z*z +c
i+=1
return i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment