[Jprogramming] Mandelbrot
Devon McCormick
devonmcc at gmail.com
Sat Aug 19 17:02:41 HKT 2006
Here's a start (probably based on Gene McDonnell's (?)) old sig of a few
years back:
NB. Make 361x600 matrix of complex numbers.
$ary=. (159%~i:_180) j.~/ 230%~_480+i.600
361 600
NB. Sum the squares of this matrix, recursively,
NB. 10 times; takes less than 1 second.
6!:2 'resultIter=. ((+*:)^:10 0:) ary'
0.97362
NB. Bucket the results according to how many are
NB. greater than each of 0 through 15.
clr0=. +/(i. 16) </ |resultIter
NB. Count how many in each bucket.
+/ (,clr0) =/ i. 16
2 68576 5547 1662 997 709 496 401 380 298 275 212 192 200 144 155
NB. Sum squares, again 10 times, of previous
NB. result: takes less than 2 seconds.
6!:2 'resultIter=. ((+*:)^:10 0:) resultIter'
1.76382
NB. Again, bucket results to give us next layer of
NB. colors: clr1.
clr1=. +/(i. 16) </ |resultIter NB. Repeat this whole process 4 more
times.
6!:2 'resultIter=. ((+*:)^:10 0:) resultIter'
2.07477
clr2=. +/(i. 16) </ |resultIter
6!:2 'resultIter=. ((+*:)^:10 0:) resultIter'
2.04566
clr3=. +/(i. 16) </ |resultIter
6!:2 'resultIter=. ((+*:)^:10 0:) resultIter'
2.04578
clr4=. +/(i. 16) </ |resultIter
6!:2 'resultIter=. ((+*:)^:10 0:) resultIter'
2.04922
clr5=. +/(i. 16) </ |resultIter
NB. Notice how distribution keeps shifting left:
NB. as successive iterations push more points to
NB. higher values (except for those in actual set).
+/ (,clr5) =/ i. 16
2058 60728 51 6 2 2 2 0 0 0 1 0 0 0 2 0
$,clr5
216600
qts ''
2002 3 18 15 22 3.475
NB. Take a look at summary result of all 6 layers.
viewmat clr0+clr1+clr2+clr3+clr4+clr5
Good luck - hope this is enough to get you started.
On 8/19/06, Ahmad Issa <ahmadissa at gmail.com> wrote:
>
> I don't quite have the money to get the book (i'm still in highschool),
> i'd
> really appreciate it if you could write some code that i can study.
>
> regards, Ahmad
>
...
--
Devon McCormick
^me^ at acm.
org is my
preferred e-mail
More information about the Programming
mailing list