(require 'maxima)
/* HERE BEGINS MAXIMA SESSION */
(%i1) fract(xmin,xmax,ymin,ymax,nr,nc,c):=
block([maxcolor:1,maxiter:50,bound:100,
zn,zn1,m,dx,dy,k,numer:true],
m: zeromatrix(nr,nc),
dx:(xmax-xmin)/nc,
dy:(ymax-ymin)/nr,
for i:1 thru nr do
for j:1 thru nc do(
zn:(xmin+(j-1)*dx) +%i*(ymin+i*dy),
k:1,
while k<=maxiter and abs(zn)<bound do(
zn1: expand(c*zn*(1-zn)),
zn:zn1,
k:k+1),
m[i,j]:if k>maxiter then 1 else 0),
/* removes previous file fractal.pnm, if any */
system("rm fractal.pnm"),
/* saving the image in pnm format */
with_stdout("fractal.pnm",
print("P2"),
print(nr, nc),
print(maxcolor),
for i:1 thru nr do
for j:1 thru nc do
print(m[i,j])),
/* call ImageMagick and paint this sort of insect */
system("display fractal.pnm") )$
(%i2) showtime:true$
Evaluation took 0.00 seconds (0.00 elapsed) using 32 bytes.
(%i3) fract(-0.5,1.5,-1,1,300,300,1.64+0.96*%i);
Evaluation took 419.03 seconds (425.08 elapsed) using 8326622.844 KB.
(%o3) #<process 3049 :EXITED>
(%i4) /* format conversion */
system("convert fractal.pnm fractal.png")$
Evaluation took 0.02 seconds (0.08 elapsed) using 12.422 KB.
(%i5)
/* HERE ENDS MAXIMA SESSION */
--