{VERSION 5 0 "IBM INTEL NT" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Headi ng 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "# Program to make a n animated plot of Julia sets" }}{PARA 0 "" 0 "" {TEXT -1 0 "" } {MPLTEXT 1 0 1 " " }{TEXT -1 83 " Based on a program from \"Dynamic al Systems With Applications Using MAPLE\" , by " }}{PARA 0 "" 0 "" {TEXT -1 91 " Stephen Lynch, Birkhauser 2001, Chapter 15. This al gorithm implements the Chaos Game." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "##################################" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 93 " This program produces an animated plot of a sequence of Julia sets, parameterized by c." }}{PARA 0 "" 0 "" {TEXT -1 82 " Store the plot as an animated gif file and you can \+ insert it inot a webpage." }}{PARA 0 "" 0 "" {TEXT -1 80 " Time t aken for calculating: M=25, k=12; about 30 minutes ( Celeron 500) ." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 100 " \+ Here a Julia set will be stored in arrays holding the x -coordinates a nd y-coordinates of the " }}{PARA 0 "" 0 "" {TEXT -1 26 " points \+ (x1 and y1). " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 6 "M:=38:" }{TEXT -1 107 " # number of interpola ting steps between initial c and final c (= # of steps in movie). Defa ult = 38" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "k:=12:iter:=2^k : # " }{TEXT -1 59 "iter is the number of points in the Julia set. De fualt = 12" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "ao:=0.1:bo:=0 .8:" }{TEXT -1 26 " # initial c=(ao, bo)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "af:=-0.3:bf:=0.8:" }{TEXT -1 23 " # final c= (af, bf)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "da:=(af-ao)/M:d b:=(bf-bo)/M:" }{TEXT -1 69 " # da and db are the step sizes of the \+ increments (the smaller the " }}{PARA 0 "" 0 "" {TEXT -1 145 " \+ \+ # they are the smoother the movie appears; 0.06 looks fine to me)" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "x1:=array(0..M,0..iter+1): y1:=array(0..M,0..iter+1):" }{TEXT -1 37 " # these arrays hold the Ju lia sets," }}{PARA 0 "" 0 "" {TEXT -1 136 " \+ # first index is the value of c and the second index are the x-co ordinates (y-coordinate) of the points." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "for j f rom 0 to M do" }{TEXT -1 76 " # beginning of the outer for lo op (for each j compute a Julia set)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "a:=ao+j*da:b:=bo+j*db:" }{TEXT -1 69 " # increment a by da a nd b by db at each step of the outer loop" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "die:=rand(0..1): #generates random numbers 0 or 1" } }{PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "# Determine the unstable fixed poi nt " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "x1[j,0]:=Re(0.5+sqrt(0.25-(a +I*b))):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "y1[j,0]:=Im(0.5+sqrt(0. 25-(a+I*b))):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "2*abs(x1[j,0]+I*y1 [j,0]);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "for i from 0 to iter do " }{TEXT -1 76 " # beginning of the inner for loop to draw the p oints of the Julia set" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "x:=x1[j,i ]:y:=y1[j,i]:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "u:=sqrt((x-a)^2+(y -b)^2)/2:v:=(x-a)/2:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "u1:=evalf(s qrt(u+v)):v1:=evalf(sqrt(u-v)):" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 71 " x1[j,i+1]:=u1:y1[j,i+1]:=v1:if y1[j,i] " 0 "" {MPLTEXT 1 0 6 "die();" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "if (die()=0) then x1[j,i+1]:=-u1:y1[j,i+1]:=-y1[j,i+1 ]:fi:od:" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 40 " \+ # end of inner for loop" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "od:" } {TEXT -1 27 " # end of outer for loop" }}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 10 " Plotting" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 130 " with(plots,animate):animate([x1[t,m],y1[t,m],m=0..iter],t=0..M,numpoin ts=iter+1,color= black,style=point,symbol=point,frames=M+1);" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 146 " This plots the array cont aining the Julia sets (parameterized by the first index, which is the \+ value of c). It is treated as a parameterized " }}{PARA 0 "" 0 "" {TEXT -1 152 " family of curves, the parameter t running from 0 (i nitial c) to M (final c). Once this plot is made you can save it using the export option in the " }}{PARA 0 "" 0 "" {TEXT -1 39 " plottin g menu; save as a gif file. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{MARK "6 0 1" 59 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 0 1 2 33 1 1 }