Appendix: Why Thomasina's algorithm works

The fact that the above algorithm works is no mystery. The reason is that we can decompose a fern into self-similar copies of itself. Look closely at Figure 7: do you see several pieces of the fern that resemble the entire fern, only in miniature? If you remove the two lowest fronds of the fern and a piece of the stem, then what remains is more or less an exact copy of the original fern, only slightly smaller. Indeed, we can obtain this smaller piece of the fern by taking the entire fern and applying our first contraction to it. That is, we compress the fern from both sides and the bottom and rotate a bit to get the smaller piece.

Also, note how the two lowest fronds of the fern are arranged. We may obtain the left hand frond by compressing the original fern by a much larger amount, and then rotating to the left. The right hand frond is obtained by first flipping the entire fern along its vertical axis, then contracting and rotating to the right. Finally, the piece of the stem that was removed can be obtained by squashing the entire fern to the center and then down, exactly our contraction number 4.

So we have divided the fern into four "self-similar" copies of itself, i.e., copies that can be obtained by applying the linear rules above. The mathematical theorem behind all of this says that, when we iterate the above rules, the resulting image is exactly what we started with, the fern. We use different probabilities here so that the density of points will be more or less even when the iteration is complete (there are more points to be drawn in the square given by contraction number 1 than by number 4).

The Formulas

Since the four contractions that produce the fern are affine transformations of the plane, they may be encoded using matrices, vectors, or other mathematical formulations. Each transformation is of the form

V new = A V old + W

where V old is the vector representing the seed, V new is the new position of the point, A is a 2 by 2 matrix, and W is a constant vector. Equivalently, the contraction may be written in coordinate form as

x1 = a x0 + b y0 + w1
y1 = c x0 + d y0 + w2

Here,

V old = x0, y0
V new = x1, y1
W = w1, w2

and the entries of A are a, b, c, and d.

For example, contraction 1 is given by

x1 = 0.85 x0 + 0.04 y0 + 0
y1 = -0.04 x0 + 0.85 y0 + 1.60

Contractions 2 and 3 take the form

x1 = 0.20 x0 + -0.26 y0 + 0
y1 = 0.23 x0 + 0.22 y0 + 1.60

x1 = -0.15 x0 + 0.28 y0 + 0
y1 = 0.26 x0 + 0.24 y0 + 0.44

Finally, contraction 4 is given by

x1 = 0 x0 + 0 y0 + 0
y1 = 0 x0 + 0.16 y0 + 0

The square involved is given by -5 < x < 5 and 0 < y < 10.