Graphic performance test #3/3 : NumWorks (Python) vs HP Prime (HPPPL non-CAS)
Mandelbrot fractal using complex numbers in interpreted languages.
NumWorks (v1.2.0) and HP Prime (v13011) comparison.
NumWorks code in Python (firmware 1.2.0+) :
import kandinsky
def mandelbrot(W,H,N) :
for x in range(W):
for y in range(H):
z=complex(0,0)
c=complex(2.7*x/(W-1)-2.1,-(1.87*y/(H-1)-.935))
j=0
while j {less than} N and abs(z) {less than} 2:
j=j+1
z=z*z+c
t=255*j/N
kandinsky.set_pixel(x,y,kandinsky.color(int(t),int(.75*t),int(.25*t)))
HP Prime code in HPPPL non-CAS :
EXPORT fractal(w,h,n)
BEGIN
local x,y,z,c,j,t
FOR x FROM 0 TO w-1 DO
FOR y FROM 0 TO h-1 DO
z:=0
c:=2.7*x/(w-1)-2.1-i*(1.87*y/(h-1)-.935)
j:=0
WHILE j {less than} N AND abs(z) {less than} 2 DO
j:=j+1
z:=z*z+c
END;
t:=255*j/N
PIXON_P(x,y,RGB(IP(t),IP(.75*t),IP(.25*t)))
END;
END;
FREEZE
WAIT(0)
#end