Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Path: pub / 1-101 / 34.sagews
Views: 168738
Image: ubuntu2004
I = CDF.0;
n = 300; x = float(200); y = float(200); x1 = float(-2); x2 = float(2); y1 = float(-2); y2 = float(2);
def atkrenta(c): du = float(2); z = c; i = 0; for i in range(n): z *= z; z += c; if (float(z.abs()) > du): break; return i;
p = []; for i in range(n): p.append([]); for r in srange(x1, x2, ((x2-x1)/x)): for i in srange(y1, y2, ((y2-y1)/y)): c = CDF(r,i) atkrito = atkrenta(c); p[atkrito].append([r, i]);
Mandelbrot_set = []; for i in range(Integer(1), n): if (len(p[i]) >= Integer(1)): Mandelbrot_set.append(p[i]); P = Graphics(); kiekis = int(len(Mandelbrot_set)); sp = int(256); max_raudona = 0; min_raudona = sp^4; for i in range(kiekis): dalis = int(i*sp^3); dalis /= kiekis; raudona = (dalis%sp); zalia = ((dalis/sp)%sp); melyna = (((dalis/sp)/sp)%sp); P += list_plot(Mandelbrot_set[i], rgbcolor=(1-(Integer(raudona)/sp),1-(Integer(zalia)/sp),1-(Integer(melyna)/sp)));
P.show()
N=100 #resolution of the plot L=100 #limits the number of iterations x0=-2; x1=1; y0=-1.5; y1=1.5 #boundary of the region plotted R=3 #stop after leaving the circle of radius R m=matrix(N,N) for i in range(N): for k in range(N): c=complex(x0+i*(x1-x0)/N, y0+k*(y1-y0)/N) z=0 h=0 while (h<L) and (abs(z)<R): z=z*z+c h+=1 m[i,k]=h matrix_plot(m)
forget(); N=int(100) #resolution of the plot L=int(50) #limits the number of iterations x0=float(-2); x1=float(1); y0=float(-1.5); y1=float(1.5) #boundary of #the region plotted R=float(3) #stop after leaving the circle of radius R zero = int(0) m=matrix(N,N) for i in range(N): for k in range(N): c=complex(x0+i*(x1-x0)/N, y0+k*(y1-y0)/N) z=zero h=zero while (h<L) and (abs(z)<R): z=z*z+c h+=1 m[i,k]=h matrix_plot(m)