Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. #Create an array of points to be checked
  5. points = np.arange(-100, 101)
  6.  
  7. #The function that checks for convergence
  8.     #If after 100 iterations abs(var) < 2 -- return True
  9.     #Return False otherwise
  10. def conv(x, y):    
  11.     c = complex(x,y)
  12.     var = c
  13.     for i in range(100):
  14.         if abs(var) > 2:
  15.             return False
  16.         var = var**2 + c        
  17.     return True
  18.  
  19. #Plots the set
  20. for i in range(201):
  21.     for j in range(201):
  22.         if conv(points[i]/50, points[j]/50):
  23.             plt.scatter(points[i]/50, points[j]/50, c = 'b', s = 1, marker = '.')
  24. plt.xlim(-2,2)
  25. plt.ylim(-2,2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement