Mandelbrot approximation - 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: Mandelbrot approximation (/thread-210.html) Mandelbrot approximation - Tugdual - 12-22-2013 09:29 PM This is an approximation which uses the triangle_p function to display the Mandelbrot set. This is much faster about 20 secs) than iterating through all pixels but still fairly slow and the resulting image is blur (a bit like over compressed jpeg). It also consumes a fair amount of memory due to usage of very large matrices. In other words, this is not very nice nor practical, just experimental... Possible improvements: - is it possible to somehow use the ITERATE function and achieve faster results? - would be nice to use cursor and zoom (may be with a box?) - implement better palette If anybody can think of possible optimizations, please do not hesitate to share ideas. Code: ``` grid, color; func(c); export Mandel() begin local cx:=-0.5, cy:=0, zoom:=80, N:=100; local minx,miny,dx,dy; minx:= cx-160/zoom; miny:=cy-119/zoom; dx:=320/N/zoom; dy:=240/N/zoom; // Create the grid grid:=makemat(((I-1)*320/N,(J-1)*240/N),N+1,N+1); color:=makemat(func((minx+I*dx,miny+J*dy)),N+1,N+1); triangle_p(G0,grid,color); wait(0); end; func(c) begin local idxcolor,i:=0, z:=0, max:=50; while i=2 then        idxcolor:=2*pi*i/max;       return RGB(255*(1+sin(idxcolor))/2,0,255*(1+cos(idxcolor))/2);     end;    i:=i+1; end; return RGB(0,0,0); end;``` RE: Mandelbrot approximation - ww63 - 10-23-2014 07:35 AM with FW 6031 (Emulator) this sample Fails with "invalid enty" at the triangle_p function call. RE: Mandelbrot approximation - StephenG1CMZ - 09-20-2015 01:11 PM It also fails with an invalid entry in the triangle call in the Android emulator.