"Whither Mathematics"

Mathematica  code as it appeared in Mathematica in Education, 
Volume 1, No. 3, Spring 1992.

Book review by 
Paul Wellin
Department of Mathematics
Sonoma State University
wellin@sonoma.edu

Barnsley's Fern

f1[{x_,y_}] = {.85x + .04y, -.04x + .85y + 1.6};
f2[{x_,y_}] = {-.15x + .28y, .26x + .24y + .44};
f3[{x_,y_}] = {.2x - .26y, .23x + .22y + 1.6};
f4[{x_,y_}] = {0, .16y};

f[x_] := Which[(r=Random[]) <= .85, f1[x],
	r <= 0.92, f2[x],
	r <= 0.99, f3[x],
	r <= 1.00, f4[x]]

Fern[n_] := Show[Graphics[{PointSize[.001],
	Map[Point, NestList[f, {0,0}, n]]}],
		PlotRange->All,AspectRatio->Automatic]

Fern[20000]

If the above command cannot be executed due to memory limitations, the PostScript can be written to a file using the following commands:

$Display = OpenWrite["PSFern"]
Fern[20000];
Close["PSFern"]
$Display = "stdout";