Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code golf: the Mandelbrot set

People also ask

How do you code a Mandelbrot set?

The Mandelbrot set is the set obtained from the recurrence relation, Z_(n) = Z²_(n-1) + c, where, Z_(0) = c. where c is a complex number” — Wolfram Mathworld. The colors in a Mandelbrot set represents the iterations at which that complex number diverges to infinity (we can use here some threshold instead of infinity).

Is there an end to the Mandelbrot set?

Yet no matter how far you zoom in, there is no end in sight to the level of detail and intricacy contained in the fractal. The Mandelbrot set is the set of all complex numbers that do not “blow up” under iteration of the complex-valued function f(z) = z²+c, starting at z=0.

What is the Mandelbrot set simple explanation?

The term Mandelbrot set is used to refer both to a general class of fractal sets and to a particular instance of such a set. In general, a Mandelbrot set marks the set of points in the complex plane such that the corresponding Julia set is connected and not computable.

Is C =- 1 I in the Mandelbrot set?

From our previous calculations, we see that c = 0, -1, -1.1, -1.3, -1.38, and i all lie in the Mandelbrot set, whereas c = 1 and c = 2i do not. The Mandelbrot set is named after the mathematician Benoît Mandelbrot who was one of the first to study it in 1980.


There was a perl solution already some years ago posted in perlmonks, it reads:

#!/usr/bin/perl
 $r=25; $c=80;
                                              $xr=6;$yr=3;$xc=-0.5;$dw=$z=-4/
                                              100;local$";while($q=$dr=rand()
                                             /7){$w+=$dw;$_=join$/,map{$Y=$_*
                                             $yr/$r;
  join""                                    ,map{$                  x=$_*$
 xr/$c;($                                   x,$y)=                 ($xc+$x
  *cos($                                   w)-$Y*               sin$w,$yc+
                                           $x*sin              ($w)+$Y*cos
  $w);$                                   e=-1;$                    a=$b=0
;($a,$b)   =($u-$v+$x,2*$a*               $b+$y)                    while(
$ u=$a*$   a)+($v=$b*$b)<4.5  &&++$e     <15;if                     (($e>$
  q&&$e<   15)||($e==$q and   rand()     <$dr))  {$q=$e;($d0,$d1)   =($x,$
  y); }                        chr(+(   32,96,+  46,45,43,58,73,37  ,36,64
 ,32)[$                        e/1.5]   );}(-$   c/2)..($c/2)-1;}   (-$r/2
 )..($     r/2)-1;select$",     $",$", 0.015;                       system
$^O=~m     ~[wW]in~x?"cls":     "clear";print                       ;$xc=(
$d0+15     *$xc)/16;$yc=($       d1+15*$yc)/                        16;$_*=
1+$z for                         $xr,$yr;$dw                     *=-1 if rand
()<0.02;                          (++$i%110                      )||($z*=-1)}

which is a "Mandelbrot explorer".

(It rotates, zooms in & out, and scrolls randomly to examine regions of the Mandelbrot set it deems "interesting.", according to it's creator.)

It doesn't exactly follow the specs named here but makes an interesting entry (imho). Maybe a simple Mandlebrot is not very interesting for the perl gods ;.-)

Regards

rboo


J, greyscale graphical output with levels, 170 characters.

load'viewmat'
c=:>(<:;|:;0$])((2$>:@+:)$-:%~i:)300
(2.5*|:3 99$i._99)viewmat {:99&<.@;@(({:+4&<@:({.+1&{)@:*:);~(0{c)&+@({.-1&{)@:*:,:(1{c)&+@:+:@({.*1&{))^:99 c

alt text http://i40.tinypic.com/2i7lm0.jpg

J, graphical output with levels, 151 characters.

load'viewmat'
c=:>(<:;|:;0$])((2$>:@+:)$-:%~i:)99
viewmat {:99&<.@;@(({:+4&<@:({.+1&{)@:*:);~(0{c)&+@({.-1&{)@:*:,:(1{c)&+@:+:@({.*1&{))^:99 c

Output:

alt text http://i40.tinypic.com/6ynxap.jpg

J, graphical output, 124 characters.

load'viewmat'
c=:>(<:;|:)((2$>:@+:)$-:%~i:)200
viewmat 4>:({.+{:)@:*:(5<.>@(({.c)&+@({.-{:)@:*:;({:c)&+@:+:@({.*{:)))^:999 c

Basically just runs "viewmat" on the ascii output.

alt text http://i40.tinypic.com/etv5lf.jpg

J, ASCII, 101 characters.

c=:>(<:;|:)((2$>:@+:)$-:%~i:)20
4>:({.+{:)@:*:(5<.>@(({.c)&+@({.-{:)@:*:;({:c)&+@:+:@({.*{:)))^:999 c

Wasted 6 characters to properly parametrize the size.

J, ASCII, 95 characters.

c=:>(<:;|:)41 41$10%~i:20
4>:({.+{:)@:*:(5<.>@(({.c)&+@({.-{:)@:*:;({:c)&+@:+:@({.*{:)))^:999 c

It doesn't do multiple levels of greyscale yet.

Explanation (currently out of date, will update later):

i:20

Generate the list of integers from -20 to 20.

10%~i:20

Divide them all by 10 (% is divide, ~ is invert order of arguments.

41 41$10%~i:20 

Fill this list into a 41x41 array, with wrapping.

(-&1;|:)41 41$`10%~i:20`

Append to this array a second array of the same size, but transposed. -&1 subtracts one from each element, ; is append, |: is transpose. Now we have a 2x41x41 array, where the first 41x41 array contains the "x0" values of each coordinate and the second contains the "y0" values.

4<:~({.+{:)@:*:(5<.>@(({.c)&+@:({.-{:)@:*:;({:c)&+@:+:@:({.*{:)))^:1000 ($c)$0

Wow. Let's break this up from the right.

($c)$0

This creates a second 2x41x41 array (the same size as c), filled with 0s. This is going to be the variable we're iterating on - basically the first array contains the "x" values and the second contains the "y" values.

^:1000 means "Repeat the previous thing in parentheses 1000 times. This is our loop counter.

(5<.>@(({.c)&+@:({.-{:)@:*:;({:c)&+@:+:@:({.*{:))

This is the next big chunk. It's basically doing one iteration of the loop. First we generate x with (({.c)&+@:({.-{:)@:*:, then join ; it to y ({:c)&+@:+:@:({.*{:)

   (({.c)&+@:({.-{:)@:*:

This generates x (remember it's operating on that 2x41x41 array representing x and y). First it squares *: each element, then does {. - {:, or x^2 - y^2. {. selects the first 41x41 array and {: the second. @: joins functions together.

To x^2-y^2, we need to add x0 - this is the first 41x41 array of c so we can do this with ({.c)&+ - & curries {.c (x0) into +.

({:c)&+@:+:@:({.*{:)

We generate y in a similar fashion. First we pairwise multiply the input x {. and y {: arrays, double the result with +:, and add y0 {:c.

The last step of this function is simply 5<.> - unboxing the join of the two new x and y arrays, and capping at 5 - it's ok since this function is monotonically increasing above 4, and we'll get out-of-bounds integers if we don't cap the values on each iteration.

4>:({.+{:)@:*:

The last step, once we've finished iterating. We square the x and y arrays *:, add them together {.+{:, and make a boolean array that's true for every element that's >: less than 4.

Output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Python 108 (was 122):

for a in range(900):print"\n.x"[(a%30>0)+(abs(reduce(lambda z,c:z*z+c,[a%30*.1-2+1j*(a/30*.1-1.5)]*30))<2)],

That last "30" is the iteration count, not one of the dimensions.
Output looks thus:

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . x . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . x x . . . . . . . . . . 
. . . . . . . . . . . . . . . . . x x . . . . . . . . . . 
. . . . . . . . . . . . . . x . x x x x x . . . . . . . . 
. . . . . . . . . . . . . . x x x x x x x x x . . . . . . 
. . . . . . . . . . . . . x x x x x x x x x x . . . . . . 
. . . . . . . . . x . . . x x x x x x x x x x . . . . . . 
. . . . . . . . x x x . x x x x x x x x x x x x . . . . . 
. . . . . . . x x x x x x x x x x x x x x x x . . . . . . 
x x x x x x x x x x x x x x x x x x x x x x . . . . . . . 
. . . . . . . x x x x x x x x x x x x x x x x . . . . . . 
. . . . . . . . x x x . x x x x x x x x x x x x . . . . . 
. . . . . . . . . x . . . x x x x x x x x x x . . . . . . 
. . . . . . . . . . . . . x x x x x x x x x x . . . . . . 
. . . . . . . . . . . . . . x x x x x x x x x . . . . . . 
. . . . . . . . . . . . . . x . x x x x x . . . . . . . . 
. . . . . . . . . . . . . . . . . x x . . . . . . . . . . 
. . . . . . . . . . . . . . . . . x x . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . x . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Now going to update based on the updated rules....


Haskell (185 chars, with all the features required in the question)

Using complex numbers and actually counting the required number of iterations (unlike the "simple" version in my other answer).

import Complex
i v=show(length$takeWhile((<=4).magnitude)$take 1000$iterate(\c->c*c+v)v)!!0
r t=[-2,4/read t-2..2]
main=getLine>>=(\[s,t]->mapM_ putStrLn[[i$x:+y|x<-r s]|y<-r t]).words

The dimensions of the resulting image are read from stdin. The output is "colored" according to the number of required iterations:

$ ./fract
60 30
1111111111111111111111111111111111111111111111111111111111111
1111111111111112222222222222222111111111111111111111111111111
1111111112222222222222222222222222222111111111111111111111111
1111112222222222222222222222222222222222111111111111111111111
1112222222222222222222222222222222222222222111111111111111111
1222222222222222222222333333333322222222222221111111111111111
2222222222222222223333333344443333332222222222211111111111111
2222222222222233333333344458755443333322222222222111111111111
2222222222233333333344445568117544433333222222222211111111111
2222222233333333344445556711111765544333322222222221111111111
2222233333333444445562391112161568786443332222222222111111111
2223333334444455556681111111111111157544333222222222211111111
2333334445617677777911111111111111111854333222222222211111111
3333444456681131231111111111111111111654333322222222221111111
3444555671111111111111111111111111114644333322222222221111111
2569888111111111111111111111111111296544333322222222221111111
3444555671111111111111111111111111114644333322222222221111111
3333444456681131231111111111111111111654333322222222221111111
2333334445617677777911111111111111111854333222222222211111111
2223333334444455556681111111111111157544333222222222211111111
2222233333333444445562391112161568786443332222222222111111111
2222222233333333344445556711111765544333322222222221111111111
2222222222233333333344445568117544433333222222222211111111111
2222222222222233333333344458755443333322222222222111111111111
2222222222222222223333333344443333332222222222211111111111111
1222222222222222222222333333333322222222222221111111111111111
1112222222222222222222222222222222222222222111111111111111111
1111112222222222222222222222222222222222111111111111111111111
1111111112222222222222222222222222222111111111111111111111111
1111111111111112222222222222222111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111

Delphi - 310 249 239 224 chars

ASCII version. Uses 7 levels for gradient shading.

  • Removed program P; and {$APPTYPE CONSOLE} according to (suggested by Uwe Raabe);
  • Inlined 1000 const (suggested by Uwe Raabe);
  • Inlined '8Oo;,. ' variable;
  • Changed word to integer so that the loop variable can be negative, and then changed the loop range for I from 3..38 to -5..30 so that (I-8) could be replaced by I (suggested by Eric Grange);
  • Changed 1000 to 1e3 (suggested by Eric Grange)
  • Changed type Double to Real (suggested by Luc Neville via e-mail)
  • Removed brackets while((x*x+y*y<=4)and(t<1000))do --> while(x*x+y*y<=4)and(t<1000)do (suggested by Luc Neville via e-mail)
  • Removed spaces between numbers that were followed by a keyword (so that for j:=-5 to 30 do becomes for j:=-5to 30do(Suggested by Neville via e-mail)
  • Changed loop range to for j:=8to 40do, removing the negative sign, and changed integer back to word. Compensated this offset in the formula, by changing x * x - y * y + i / 16 - 2; to x * x - y * y + i / 16 - 3;

Unreadable version:

var n,x,y:Real;t,i,j:Word;begin for j:=8to 40do begin for i:=8to 65do begin x:=0;y:=0;t:=0;while(x*x+y*y<=4)and(t<1e3)do begin n:=x*x-y*y+i/16-3;y:=2*x*y+j/12-2;x:=n;inc(t)end;Write('8Oo;,. '[t mod 7+1])end;WriteLn;end;end.

Formatted code:

var
  n, x, y: Real;
  t, i, j: Word;
begin
  for j := 8 to 40 do
  begin
    for i := 8 to 65 do
    begin
      x := 0;
      y := 0;
      t := 0;
      while (x * x + y * y <= 4) and (t < 1e3) do
      begin
        n := x * x - y * y + i / 16 - 3;
        y := 2 * x * y + j / 12 - 2;
        x := n;
        inc(t)
      end;
      Write('8Oo;,. '[t mod 7 + 1])
    end;
    WriteLn;
  end;
end.

Output:

OOOOOOOOOOOOOOOOOooooooooooooooooooooooooooooooooooooooooo
OOOOOOOOOOOOOOOOooooooooo;;;;;;;;;;;;;;;oooooooooooooooooo
OOOOOOOOOOOOOOOoooooo;;;;;;;;;;;;;;,,,,,;;;;oooooooooooooo
OOOOOOOOOOOOOOooooo;;;;;;;;;;;;;,,,, ; .,,,;;;oooooooooooo
OOOOOOOOOOOOOoooo;;;;;;;;;;;;;,,,,.. O   ,,,,;;;oooooooooo
OOOOOOOOOOOOooo;;;;;;;;;;;;;,,,,,...8oo,8..,,,;;;;oooooooo
OOOOOOOOOOOooo;;;;;;;;;;;;,,,,,,.. Oo. ; 8...,,;;;;ooooooo
OOOOOOOOOOOoo;;;;;;;;;;;;,,,,,.   8OO    O8 ..,,;;;;oooooo
OOOOOOOOOOoo;;;;;;;;;;;,,,,..  O,oO8oo ,OOoO88,.,;;;;ooooo
OOOOOOOOOOo;;;;;;;;;;,,,....  o. .         OOO  ,;;;;;oooo
OOOOOOOOOO;;;;;;;;;,,......  o.,              o .,;;;;;ooo
OOOOOOOOOo;;;;;;,,. o     88O.                ;O.,;;;;;ooo
OOOOOOOOO;;;,,,,,.. ,,o;,oOo;                  o ,,;;;;;oo
OOOOOOOOO;,,,,,... 8o;   8;,                    .,,;;;;;oo
OOOOOOOOO,,,,,... Oo       .                   8.,,;;;;;oo
OOOOOOOOO,.,.  88oo o       ,                 , .,,;;;;;oo
OOOOOOOO                                     ,8 .,,;;;;;;o
OOOOOOOOO,.,.  88oo o       ,                 , .,,;;;;;oo
OOOOOOOOO,,,,,... Oo       .                   8.,,;;;;;oo
OOOOOOOOO;,,,,,... 8o;   8;,                    .,,;;;;;oo
OOOOOOOOO;;;,,,,,.. ,,o;,oOo;                  o ,,;;;;;oo
OOOOOOOOOo;;;;;;,,. o     88O.                ;O.,;;;;;ooo
OOOOOOOOOO;;;;;;;;;,,......  o.,              o .,;;;;;ooo
OOOOOOOOOOo;;;;;;;;;;,,,....  o. .         OOO  ,;;;;;oooo
OOOOOOOOOOoo;;;;;;;;;;;,,,,..  O,oO8oo ,OOoO88,.,;;;;ooooo
OOOOOOOOOOOoo;;;;;;;;;;;;,,,,,.   8OO    O8 ..,,;;;;oooooo
OOOOOOOOOOOooo;;;;;;;;;;;;,,,,,,.. Oo. ; 8...,,;;;;ooooooo
OOOOOOOOOOOOooo;;;;;;;;;;;;;,,,,,...8oo,8..,,,;;;;oooooooo
OOOOOOOOOOOOOoooo;;;;;;;;;;;;;,,,,.. O   ,,,,;;;oooooooooo
OOOOOOOOOOOOOOooooo;;;;;;;;;;;;;,,,, ; .,,,;;;oooooooooooo
OOOOOOOOOOOOOOOoooooo;;;;;;;;;;;;;;,,,,,;;;;oooooooooooooo
OOOOOOOOOOOOOOOOooooooooo;;;;;;;;;;;;;;;oooooooooooooooooo
OOOOOOOOOOOOOOOOOooooooooooooooooooooooooooooooooooooooooo

T-SQL (421 408 characters)

declare @s varchar(max);
with
x(x)as(select CAST(-2.0 as real)union all select x+.01 from x where x<1),
y(y)as(select CAST(-1.1 as real)union all select y+.02 from y where y<1.1),
g(x,y,u,v,g)as(select x,y,x*0,y*0,0 from x,y union all select x,y,u*u-v*v+x,2*u*v+y,g+1 from g where g<24and u*u+v*v<4),
m(x,y,v)as(select x,y,case when x<-1.99 then char(10)end+substring(' .-''^"+oiexp**##$$$§§%%%@',COUNT(*),1)from g group by x,y)
select @s=@s+v from m order by y,x option(maxrecursion 400)
select @s

Output is here:


awk - 134 135 chars

ASCII art, fully compliant. Fairly straightforward translation of the python reference implementation:

{for(j=-2;j<=2;j+=4/$2){for(i=-3;i<=1;i+=4/$1){for(x=y=k=0;x*x+y*y<=4&&++k<4^5;)
{t=x*x-y*y+i;y=2*x*y+j;x=t}printf"%d",log(k)}print""}}

test run

$ awk -f mandel.awk 
10 10
00000000000
00000000000
00000111000
00001116110
00011166610
00046666611
00011166610
00001116110
00000111000
00000000000
00000000000

and this is a VT-100 art. Set the xterm to "unreadable" characters, then try a 400x200 set:

{for(j=-2;j<=2;j+=4/$2){for(i=-3;i<=1;i+=4/$1){for(x=y=k=0;x*x+y*y<=4&&++k<1000;)
{t=x*x-y*y+i;y=2*x*y+j;x=t}printf"\x1b[4%dm ",log(k)}print"\x1b[0m"}}