> Thx. It works good.
> When I try to make image for n from 1 to 20 then it takes houres.
> In R code runs faster ( few minutes).
> What is the reason ?
>
> Adam
Adam,
(%i4) f(x,y,n) :=
block([i:0, c:x+y*%i,ER:4,iMax:n,z:0],
while abs(z)<ER and i<iMax
do (z:z*z + c,i:i+1),
min(ER,abs(z)))$
(%i5) dx : 2.7/70 $
(%i6) dy : 2.4/70 $
(%i7) for i:-2 thru 0.7 step dx do
for j:-1.2 thru 1.2 step dy do
f(i,j,4) $
(%i8) time(%o7);
(%o8) [84.30927]
It takes about 84 sec to calculate all the points for only one frame.
If you load the following lisp function, things look certainly better:
(defun $g (x y n)
(let ((er 4.0)
(c (complex ($float x) ($float y)))
(z (complex 0.0 0.0)))
(dotimes (i n)
(setf z (+ (* z z) c)))
(min er (abs z)) ))
(%i13) for i:-2 thru 0.7 step dx do
for j:-1.2 thru 1.2 step dy do
g(i,j,4) $
(%i14) time(%o13);
(%o14) [0.46803]
Sometimes it's better to write your code directly in Lisp.
--
Mario