Folder full of pertinent coursework
Kernel: Python 2 (SageMath)
In [0]:
import math class JuliaSet: def __init__(self, c, n = 100): #c is the first of two initialized values and #is a complex number that acts as a seed. #n is the other value and it is an integer of #maximum iterations. self.c = c self.n = n self._d = 0.001 self.makeplane() #_d is an instance attribute and a float. def juliamap(self, z): #z is a complex number in this method return (z ** 2 ) + self.c def iterate(self, z): m = 0 while True: z = self.juliamap(z) m += 1 if (z.real**2 + z.imag**2) > 4: return m if m >= self.n: return 0 def makeplane(self): self._complexplane = [complex(r * self._d, s * self._d) for r in range(-2000, 2000, 2) for s in range (-2000, 2000, 1)] #self._complexplane is a class instance attribute #def makeplane(self): #nmax = int(4 / self._d) #self._complexplane = [] #for x in xrange(-nmax,nmax,1): #for y in xrange(-nmax,nmax,1): #self._complexplane.append(complex(x * self._d, (y * self._d))) #self._complexplane is a class instance attribute #def makeplane(self): #self._complexplane = [] #for x in range(-2000,2000,1): #for y in range(-2000,2000,1): #self._complexplane.append(complex(x * self._d, (y * self._d))) #self._complexplane is a class instance attribute def set_spacing(self, d): self._d = d self.makeplane() def generate(self): self.set = [self.iterate(i) for i in self._complexplane] PY import math class JuliaSet: def __init__(self, c, n = 100): #c is the first of two initialized values and #is a complex number that acts as a seed. #n is the other value and it is an integer of #maximum iterations. self.c = c self.n = n self._d = 0.001 self.makeplane() #_d is an instance attribute and a float. def juliamap(self, z): #z is a complex number in this method return (z ** 2 ) + self.c def iterate(self, z): m = 0 while True: z = self.juliamap(z) m += 1 if (z.real**2 + z.imag**2) > 4: return m elif m >= self.n: return 0 def makeplane(self): nmax = int(4 / self._d) self._complexplane = [] for x in xrange(-nmax,nmax,1): for y in xrange(-nmax,nmax,1): self._complexplane.append(complex(x * self._d, (y * self._d))) #self._complexplane is a class instance attribute def set_spacing(self, d): self._d = d self.makeplane() def generate(self): self.set = [self.iterate(i) for i in self._complexplane] ANOTHER PY import math class JuliaSet: def __init__(self, c, n = 100): self.c = c self.n = n self._d = 0.001 self._e = int(2 / self._d) self.complexplane[complex(r * self._d,(s * self._d)) for s in range(-self._e, self._e,1) for r in range(-self._e,self._e,1)] def juliamap(self, z): return (z ** 2 ) + self.c def iterate(self, z): for m in range(1, self.n+1): z = self.juliamap(z) if (z.real**2 + z.imag**2) > 4: return m if m >= self.n: return 0 #def makeplane(self): #self._complexplane = [complex(r * self._d, s * self._d) for r in range(-2000, 2000, 2) for s in range (-2000, 2000, 1)] def set_spacing(self, d): self._d = d self._e = int(2 / self._d) self.complexplane[complex(r * self._d,(s * self._d)) for s in range(-self._e, self._e,1) for r in range(-self._e,self._e,1)] #def generate(self): #self.set = [self.iterate(i) for i in self._complexplane]