This book shows how to turn computer generated number sequences into intricate visual patterns. The sequences are strings of the binary numbers 0 and 1 which are translated into drawing instructions to produce beautiful patterns. These patterns provide a glimpse of the hidden platonic world of mathematics.

The book starts with Christoffel words and Sturmian sequences which are derived from the continued fraction expansion of rational and irrational numbers. How this is done is explained very clearly in the book and very little mathematical background is required from the reader.

The book moves on to Automatic sequences such as the Thue-Morse and Rudin-Shapiro sequences which are various ways of calculating digital roots of the integers. The first part of the book ends with sequences generated by folding paper.

Translating a sequence into drawing instructions is done using a finite automaton. This is a very general method for translating sequences that allows the same sequence to produce many different patterns. No prior experience with finite automata is necessary. All the background needed is explained in the book.

The second part of the book is devoted to L-systems which is another way of producing a string of drawing instructions. Here the strings are produced by an iterative symbol substitution process. The images produced often have a self similar fractal structure. It is possible to create many images that resemble plants. The book shows how to use an automaton and context free grammars to systematically look at all L-systems of a particular type.

All software used to create the sequences and images in the book are free for readers to download below.

The software consists of small programs written in the C programming language that can be run on all major operating systems. Inside the book are 327 images serving as inspiration for what you can create. There are an infinite variety of images you can generate using the software that comes with this book, providing a computational image generation lab.

You can get this book now at Amazon as a paperback, or as a Kindle ebook.

You can also get this ebook instantly as a pdf from Gumroad where you will be able to download it immediately after purchase.

**About the authors:**
Stefan Hollos
and J. Richard
Hollos are physicists by training, and enjoy anything related to
math, physics, and computing. They are the authors
of Finite
Automata and Regular Expressions: Problems and Solutions,
Probability
Problems and Solutions,
Combinatorics
Problems and Solutions,
The Coin Toss: Probabilities
and Patterns,
Bet Smart: The
Kelly System for Gambling and Investing, as well as
Simple Trading Strategies That Work
and Pairs
Trading: A Bayesian Example, and are brothers and business
partners at Exstrom Laboratories LLC in Longmont, Colorado. The
websites for their work
are Exstrom.com
and QuantWolf.com.

## Videos

These videos show some of the patterns you can create.

## Table of Contents

**Preface****Introduction****Words, Sequences and Folding****Christoffel Words****Drawing Translation****Producing a Drawing****Continued Fractions****Square Root of 3****Square Root of 5****Square Root of 17****Golden Ratio****Transcendental Numbers****Automatic Sequences****Paper Folding****Lindenmayer Systems****Formal Definition****Graphical Interpretation****Koch Curves****Edge Rewriting****Generating Images****Introducing Autogen****Coupled Production Rules****Branching****Appendix A:**`katrans`Automaton Files**Appendix B: Continued Fractions****Appendix C: Programs****Further Reading****Acknowledgements****About the Authors**

## Software

Below are the C programs that accompany the book. You can download each as you need it, or all of them bundled into a zip file. All the automaton files used in the book can also be downloaded in a zip file.

This software is free and distributed under the terms of the GNU General Public License. It is written in ANSI C and should compile with any C compiler. If you have questions or comments contact: Stefan (stefan at exstrom dot com) or Richard (richard at exstrom dot com).

**autogen.c**

Generates all words of a given length accepted by an automaton.Usage: autogen file.aut n s e1 e2 ... file.aut = automaton file n = length of words s = start state ei = end state i

**b2d.c**

Converts a binary number to decimal.Usage: d2b n

**cfcv.c**

Calculates the convergent of a continued fraction.Usage: cfcv a0 a1 a2 ... an ai = simple continued fraction term

**cfgen.c**

Generates the words of a context free grammar.Usage: cfgen file.cfg n s file.cfg = grammar file n = number of derivation steps s = start variable

**cfrac.c**

Calculates the continued fraction of a real number.Usage: cfrac x n x = number n = number of terms

**cfrat.c**

Calculates the continued fraction of the rational number p/q.Usage: cfrat p q

**cfsqrt.c**

Calculates the continued fraction of the square root of an integer.Usage: cfsqrt n n = integer

**cfsurd.c**

Calculates the continued fraction of a quadratic surd: (A+sqrt(n))/B where n, A and B are integers and n>0.Usage: cfsurd n A B n, A, B = integers, with n>0

**chseq.c**

Calculates a Christoffel sequence.Usage: chseq p q n p = numerator q = denominator n = number of terms to generate, default=p+q

**d2b.c**

Converts a decimal number to binary.Usage: d2b n

**katrans.c**

Translates a sequence of the numbers 0 to k.Usage: katrans file.kat file.kat = k-automaton file

**lsysgen.c**

Generates an L-system string given an axiom and set of production rules.Usage: lsysgen file.ldf n file.ldf = name of file with axiom and production rules. n = number of times to iterate.

**pfold.c**

Generates paper folding sequences.Usage: pfold n m f n = number of terms, 1,3,7,15,31,63,127,... m = number of bits f = function number 0 -> 2^m-1

**rndseq.c**

Generates random binary sequences.Usage: rndseq n n = number of digits to generate

**rsseq.c**

Generates the Rudin-Shapiro sequence.Usage: rsseq n n = number of terms

**tmseq.c**

Generates the Thue-Morse sequence.Usage: tmseq n n = number of terms

**turtledraw.c**

Creates an svg file from turtle drawing instructions. Input is read from stdin. Requires the Cairo graphics library.Usage: turtledraw angle dangle file.svg angle = start angle dangle = increment angle file.svg = output svg file. Example: chseq 355 113 1872 | katrans t7.kat | turtledraw 0.0 90.0 file.svg

Send comments to: Richard Hollos (richard[AT]exstrom DOT com)

Copyright 2013 by Exstrom Laboratories LLC