Fractal Plots - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Fractal Plots (/thread-13028.html) Fractal Plots - Eddie W. Shore - 05-27-2019 12:56 PM Blog Entry: http://edspi31415.blogspot.com/2019/05/fractal-plots-ti-84-plus-ce-and-hp-prime.html The program CHAOS1 plots a fractal to simulate a Julia Set. Given the complex numbers z_k and c, repeats the equation: z_n = z_n-1 + c^2 The program will ask for a sample graphing space with the a border B. The viewing window will be set up as: Xmin = -B Xmax = B Ymin = -B Ymax = B The program CHAOS1 will also as for the number of points (G), this will determine the number of points plotted in the graph. The higher G is, the more detailed the fractal is; however, the plot will take longer to complete. We start with each point on the graph z_0 = a + b*i, where i = √-1. Then we calculate: z_1 = z_0^2 + c z_2 = z_1^2 + c z_3 = z_2^2 + c and so on. For each z_0, we have two possibilities for the repeated calculations: 1. |z_n| = abs(z_n) eventually goes towards infinity or 2. |z_n| = abs(z_n) eventually settles (or converges) to a specific point. A color is assigned to each point z_0. The color is determined by the amount of iterations it takes to reach |z| > 2. For such points that fit criteria 2, and never reaches |z| >2, the point is colored black. This method creates the Julia set for any given c. For the program CHAOS1, I set up a rank of colors to plot each point, and arbitrary pick a maximum amount of iterations. For example, I picked 9 colors for the TI-84 Plus CE version. Hence for each point, if |z| ≤ 2 after 9 iterations, color the point black. Obviously the more levels (colors) we have, the more accurate our fractal is. With the programs listed, you can adjust the number of colors. I set 18 color levels, starting from white to black. Because of the faster processor and calculating speed, I have increased the number of grid points to 500. 250 makes a picture with lines. Note: I use the parenthesis notation (x,y) for the complex number x + yi because the imaginary character i unfortunately does not transfer to computer text. Code: ```EXPORT CHAOS1() BEGIN // 2019-05-19 EWS LOCAL b,g,c,l6,s; LOCAL i,k,j,z,l; STARTAPP("Function"); INPUT({b,g,{c,[[0],[3]]}},"Fractal", {"Border: ","Grid: ","C: "}, {"Min/Max - X/Y", "# Grid Pts", "C: x + yi"}); // size the screen Xmin:=−b; Xmax:=b; Ymin:=−b; Ymax:=b; // clear RECT(); // list of colors l6:={#FFFFFFh,#C0C0C0h, #D0D0D0h,#FFFF00h, #B0B0B0h,#FF8000h, #905000h,#400808h, #00FF00h,#004060h, #003000h,#00FFFFh, #80D0FFh,#0000FFh, #000080h,#400080h, #404040h,#000000h}; // plotting s:=SIZE(l6); FOR i FROM −b TO b STEP (2*b)/g DO FOR j FROM −b TO b STEP (2*b)/g DO k:=0; REPEAT  k:=k+1; IF k==1 THEN z:=(i,j); ELSE z:=z^2+c; END; UNTIL ABS(z)>2 OR k==s; l:=l6(k); PIXON(i,j,l); END; END; WAIT(0); END;``` Download the program (hpprgrm) here: https://drive.google.com/open?id=1A06e_pAPk7fMik07Pbi1tyjbLSUkVUN2 (The zip file also has a version for the TI-84 Plus CE)