Dragon curve


A dragon curve is any member of a family of self-similar fractal curves, which can be approximated by recursive methods such as Lindenmayer systems. The dragon curve is probably most commonly thought of as the shape that is generated from repeatedly folding a strip of paper in half, although there are other curves that are called dragon curves that are generated differently.

Heighway dragon

The Heighway dragon was first investigated by NASA physicists John Heighway, Bruce Banks, and William Harter. It was described by Martin Gardner in his Scientific American column Mathematical Games in 1967. Many of its properties were first published by Chandler Davis and Donald Knuth. It appeared on the section title pages of the Michael Crichton novel Jurassic Park.

Construction

It can be written as a Lindenmayer system with
That can be described this way: starting from a base segment, replace each segment by 2 segments with a right angle and with a rotation of 45° alternatively to the right and to the left:
The Heighway dragon is also the limit set of the following iterated function system in the complex plane:
with the initial set of points.
Using pairs of real numbers instead, this is the same as the two functions consisting of
This representation is more commonly used in software such as Apophysis.

Unfolding the dragon

Tracing an iteration of the Heighway dragon curve from one end to the other, one encounters a series of 90-degree turns, some to the right and some to the left. For the first few iterations the sequence of right and left turns is as follows:
This suggests a few different patterns. First, each iteration is formed by taking the previous and adding alternating rights and lefts in between each letter. Second, it also suggests the following pattern: each iteration is formed by taking the previous iteration, adding an R at the end, and then taking the original iteration again, flipping it retrograde, swapping each letter and adding the result after the R. Due to the self-similarity exhibited by the Heighway dragon, this effectively means that each successive iteration adds a copy of the last iteration rotated counter-clockwise to the fractal.
This pattern in turn suggests the following method of creating models of iterations of the Heighway dragon curve by folding a strip of paper. Take a strip of paper and fold it in half to the right. Fold it in half again to the right. If the strip was opened out now, unbending each fold to become a 90-degree turn, the turn sequence would be RRL, i.e. the second iteration of the Heighway dragon. Fold the strip in half again to the right, and the turn sequence of the unfolded strip is now RRLRRLL – the third iteration of the Heighway dragon. Continuing folding the strip in half to the right to create further iterations of the Heighway dragon.
This unfolding method can be seen by calculating a number of iterations of the curve using the "swapping" method described above, but controlling the angles for the right turns and negating prior angles.
This pattern also gives a method for determining the direction of the nth turn in the turn sequence of a Heighway dragon iteration. First, express n in the form k2m, where k is an odd number. The direction of the nth turn is determined by k mod 4, i.e. the remainder left when k is divided by 4. If k mod 4 is 1, then the nth turn is R; if k mod 4 is 3, then the nth turn is L.
For example, to determine the direction of turn 76376:
There is a simple one-line non-recursive method of implementing the above k mod 4 method of finding the turn direction in code. Treating turn n as a binary number, calculate the following boolean value:
Another way of handling this is a reduction for the above algorithm. Using Gray code, starting from zero, determine the change to the next value. If the change is a 1, then turn left, and if it is 0, then turn right. Given a binary input B, the corresponding Gray code G is given by "G = B XOR ". Using Gi and Gi−1, turn equals " AND Gi−1".
Another approach to generating this fractal can be created using a recursive function and these Turtle graphics functions drawLine and turn.
The Python code to draw an Heighway dragon curve would look like this.

def dragon_curve -> None:
"""Draw a dragon curve."""
turn
dragon_curve_recursive
def dragon_curve_recursive -> None:
if order 0:
drawLine
else:
rootHalf = **
dragon_curve_recursive
turn
dragon_curve_recursive

Dimensions

In fact it can be found analytically:
This is the root of the equation

Tiling

The dragon curve can tile the plane in many ways.

Twindragon

The twindragon can be constructed by placing two Heighway dragon curves back to back. It is also the limit set of the following iterated function system:
where the initial shape is defined by the following set.
It can be also written as a Lindenmayer system – it only needs adding another section in initial string:
The terdragon can be written as a Lindenmayer system:
It is the limit set of the following iterated function system:

Lévy dragon

The Lévy C curve is sometimes known as the Lévy dragon.

Variants

It is possible to change the turn angle from 90° to other angles. Changing to 120° yields a structure of triangles, while 60° gives the following curve: is clearly visible.
A discrete dragon curve can be converted to a dragon polyomino as shown.
Like discrete dragon curves, dragon polyominoes approach the fractal dragon curve as a limit.

Occurrences of the dragon curve in solution sets

Having obtained the set of solutions to a linear differential equation, any linear combination of the solutions will, because of the superposition principle, also obey the original equation. In other words, new solutions are obtained by applying a function to the set of existing solutions. This is similar to how an iterated function system produces new points in a set, though not all IFS are linear functions.
In a conceptually similar vein, a set of Littlewood polynomials can be arrived at by such iterated applications of a set of functions.
A Littlewood polynomial is a polynomial: where all.
For some we define the following functions:
Starting at z=0 we can generate all Littlewood polynomials of degree d using these functions iteratively d+1 times. For instance:
It can be seen that for, the above pair of functions is equivalent to the IFS formulation of the Heighway dragon. That is, the Heighway dragon, iterated to a certain iteration, describe the set of all Littlewood polynomials up to a certain degree, evaluated at the point.
Indeed, when plotting a sufficiently high number of roots of the Littlewood polynomials, structures similar to the dragon curve appear at points close to these coordinates.