Skip to the page
Spiral, Fern & Honeycomb

Every pattern is a short rule played long.

L-System Plants: One Rewrite Rule Draws a Branching Weed

In brief

An L-system is a set of rewrite rules, introduced in 1968 by Lindenmayer according to the preface of The Algorithmic Beauty of Plants full text, that replaces all the letters of a string at once; here the string is then read as drawing steps. The branching weed of that book's Fig. 1.24(a), p. 25, needs a single rule, F becomes F[+F]F[-F]F, with a turning angle of 25.7 degrees; after four rewrites the string holds 1,561 symbols and draws 625 line segments. The rule draws a weed-like outline; it does not show how a real plant grows.

Pattern card

Pattern
A branching weed drawn from one rewrite rule: each line becomes five lines with one side branch to the left and one to the right, step after step
Where
Drawn plant models in The Algorithmic Beauty of Plants; on this page set beside photographs of real branching weeds
Made by
branching: simulation-only (the rule draws a weed-like shape; a real plant is not shown to grow from a string)
Shortest recipe
1 rule / 1 parameter: F -> F[+F]F[-F]F; delta=25.7 deg; shortest of 5 candidates in this page's comparison record; steps and step length are display settings
Key source
Prusinkiewicz & Lindenmayer 1990, The Algorithmic Beauty of Plants, Fig. 1.24(a), p. 25 full text

This card as CSV file notes: source and license

Data: Prusinkiewicz & Lindenmayer 1990, The Algorithmic Beauty of Plants, Fig. 1.24(a), p. 25

Branching weed on asphalt: thin flowering stems rise from a leaf rosette; Capsella bursa-pastoris per the file page

A whole weed laid on asphalt with its roots showing, named Capsella bursa-pastoris on its file page; its flowering stems fork off near the base and branch again higher up.

"Starr 070308-5329 Capsella bursa-pastoris" by Forest & Kim Starr — https://commons.wikimedia.org/wiki/File:Starr_070308-5329_Capsella_bursa-pastoris.jpg — CC BY 3.0 (https://creativecommons.org/licenses/by/3.0/); modified: resized from 2,112 x 2,816 to 900 x 1,200 pixels and saved as WebP

Write F on a sheet of paper, then replace it with F[+F]F[-F]F and repeat. Each round swaps all the F's at once, so a single F becomes 5, then 25, then 125. Read as instructions for a pen, the lengthening string draws a weed whose branches carry smaller branches of their own.

What is an L-system?

An L-system is a procedure for growing a string of symbols by repeated substitution. A rule, called a production, says what each letter turns into, and all the letters are replaced in the same step. The Algorithmic Beauty of Plants, by Przemyslaw Prusinkiewicz and Aristid Lindenmayer (1990), puts the difference from Chomsky grammars, which apply rules one after another, this way: in L-systems the rules “are applied in parallel and simultaneously replace all letters in a given word” (p. 3).

The string becomes a picture when a pen, called a turtle in the book, follows it one symbol at a time:

  1. F: draw one step forward.
  2. +: turn left by the angle delta.
  3. -: turn right by delta.
  4. [: remember the pen's position and heading.
  5. ]: jump back to the last remembered position and heading.

The brackets make the branches. The book describes [ as pushing the turtle's state onto a stack and ] as retrieving it (p. 24), so everything between a pair of brackets becomes a side branch, and the drawing then continues from the position where that branch began.

Branching weed, Fig. 1.24(a) rule redrawn: one line at n=0, then 0 to 4 rewrites with branches on branches, delta 25.7

Full-size figure

The rule of Fig. 1.24(a), drawn here from the printed rule for 0 to 4 rewrites, each panel scaled to the same height; the book's own figure goes one step further, to 5.

Recipe F -> F[+F]F[-F]F; delta=25.7; n=0-4 (ABOP Fig. 1.24(a), p. 25)

"L-system weed, Fig. 1.24(a) rule, 0 to 4 rewrites" by Spiral, Fern & Honeycomb, https://spiralfernandhoneycomb.com/branching/l-system/, licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/).

Data: Rule F -> F[+F]F[-F]F and angle 25.7 degrees from Prusinkiewicz & Lindenmayer 1990, The Algorithmic Beauty of Plants, Fig. 1.24(a), p. 25

Each rewrite multiplies the number of F's by five, because each F is replaced by a string containing five of them. Counted on this page's strings:

Rewrites (n)Symbols in the stringF's (line segments)Branches opened
0110
11152
2612512
331112562
41,561625312

This table as CSV (l-system-generations.csv) (file notes: source and license) Data: Rules from Prusinkiewicz & Lindenmayer 1990, The Algorithmic Beauty of Plants, Fig. 1.24, p. 25; counts computed on this site

The rule stays one line long, while the string it generates grows more than five times longer at each step. Each figure regrown sets out how the counts were checked.

How do a few rewrites grow a plant?

One small edit to the rule alters the whole plant. Fig. 1.24(b) on the same page puts the last F of the rule in brackets, F[+F]F[-F][F], and uses a smaller angle of 20 degrees.

Because the pen jumps back after that bracketed F, the rest of the plant grows from the point below it rather than from its tip, so from the second rewrite on, several shoots can leave one point. After four rewrites the string has 1,873 symbols and still 625 F's, but it opens 468 branches instead of 312, so the plant looks denser and bushier.

Bushier weed, Fig. 1.24(b) rule redrawn: 0 to 4 rewrites, last F bracketed so shoots crowd at shared points, delta 20

Full-size figure

The rule of Fig. 1.24(b), drawn here from the printed rule for 0 to 4 rewrites; with the last F in brackets, later growth starts below each segment's tip, so shoots crowd at shared points.

Recipe F -> F[+F]F[-F][F]; delta=20; n=0-4 (ABOP Fig. 1.24(b), p. 25)

"L-system weed, Fig. 1.24(b) rule, 0 to 4 rewrites" by Spiral, Fern & Honeycomb, https://spiralfernandhoneycomb.com/branching/l-system/, licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/).

Data: Rule F -> F[+F]F[-F][F] and angle 20 degrees from Prusinkiewicz & Lindenmayer 1990, The Algorithmic Beauty of Plants, Fig. 1.24(b), p. 25

Both weeds grow the same way on paper: at each step, each segment, whether old or new, is replaced by five segments, some of them on new side branches. That is a procedure for drawing, and the drawing order says nothing about the sequence in which a real plant's stems appear.

Can two different rules draw a similar plant?

Yes, and the same page of the book shows two of them. Figs. 1.24(d) and (e) introduce a second letter, X, that the pen ignores: it marks a position where new branches will appear. Their rules are X becomes F[+X]F[-X]+X for (d) and X becomes F[+X][-X]FX for (e), and both add F becomes FF, so each existing segment doubles in length at each step.

Node-rewriting plant, Fig. 1.24(d) rule redrawn: 0 to 4 rewrites from one dot, stems splitting in two, delta 20

Full-size figure

"L-system plant, Fig. 1.24(d) rule, 0 to 4 rewrites" by Spiral, Fern & Honeycomb, https://spiralfernandhoneycomb.com/branching/l-system/, licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/).

Data: Rules X -> F[+X]F[-X]+X, F -> FF and angle 20 degrees from Prusinkiewicz & Lindenmayer 1990, The Algorithmic Beauty of Plants, Fig. 1.24(d), p. 25

Node-rewriting plant, Fig. 1.24(e) rule redrawn: 0 to 4 rewrites from one dot, side shoots leaving in threes, delta 25.7

Full-size figure

"L-system plant, Fig. 1.24(e) rule, 0 to 4 rewrites" by Spiral, Fern & Honeycomb, https://spiralfernandhoneycomb.com/branching/l-system/, licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/).

Data: Rules X -> F[+X][-X]FX, F -> FF and angle 25.7 degrees from Prusinkiewicz & Lindenmayer 1990, The Algorithmic Beauty of Plants, Fig. 1.24(e), p. 25

The rules of Fig. 1.24(d), first, and (e), second, drawn here from the printed rules for 0 to 4 rewrites; the dot at n=0 is the undrawn letter X. The book's figures go to 7 rewrites.

Recipe (d) X -> F[+X]F[-X]+X, F -> FF, delta=20; (e) X -> F[+X][-X]FX, F -> FF, delta=25.7; n=0-4 (ABOP Fig. 1.24, p. 25)

After four rewrites the two plants have the same counts on this page's strings: 130 segments and 27 tips each. The branching differs. Plant (d) has 26 points where the stem splits in two; plant (e) has 13 points where three shoots leave together.

Which rule is the shortest recipe?

The shortest recipe is this site's name for the rule that ranks shortest among the candidates in a page's comparison record while still passing a stated check. Rules and parameters are counted, and fewer of both together ranks first; on a tie, fewer parameters wins.

Here the check asks which candidates rebuild the branching of the Fig. 1.24(a) weed after 5 rewrites, the step count of the book's figure. It compares four features: 1,563 tips, 1,562 branch points, at most 2 shoots at one point and a deepest branch level of 5. Each candidate was rewritten from step 1 until all four features matched, or up to step 9 if none did, and the angle does not enter the check.

Candidate ruleRules / parametersRebuilds Fig. 1.24(a)?Where it comes from
F -> F[+F]F[-F]F; delta1 / 1yes, at step 5Fig. 1.24(a)
F -> F[+F]F[-F][F]; delta1 / 1noFig. 1.24(b)
F -> F[+F]F[-F]F; left and right angles1 / 2yes, at step 5a variant set up on this site
X -> F[+X]F[-X]+X; F -> FF; delta2 / 1noFig. 1.24(d)
X -> F[+X][-X]FX; F -> FF; delta2 / 1noFig. 1.24(e)

This table as CSV (l-system-recipes.csv) (file notes: source and license) Data: Candidate rules (a), (b), (d) and (e) from Prusinkiewicz & Lindenmayer 1990, The Algorithmic Beauty of Plants, Fig. 1.24, p. 25; checks computed on this site

The book's own rule passes, as it must, since the target is the branching that rule produces. The record shows which neighbors also pass and at what cost: the two-angle version passes with one more parameter, and the other three fail.

The shortest recipe in this record is the Fig. 1.24(a) rule, 1 rule and 1 parameter. It is the shortest of these five, not the shortest rule that could ever draw this weed.

Do real plants grow like this?

Not by this page's reading. The book's caption for Fig. 1.24 presents the drawings as examples of structures that look like plants (p. 25). Its opening chapter explains the parallel rewriting by a different picture: the rules are meant to capture cell divisions in organisms made of many cells, where many divisions may happen at the same time (p. 3).

A drawing that resembles a weed demonstrates that a short rule can produce that outline. It does not demonstrate that a weed constructs itself by rewriting a string, so the Pattern card classifies the rule as a simulation only.

Weeds on a stone wall, Arabidopsis thaliana per the file page: flowering stems of uneven height rise from leaf rosettes

Small flowering weeds on a stone wall at a castle ruin in Lower Austria, named Arabidopsis thaliana on the file page; on this photograph the stems rise at uneven heights and lengths, unlike the strict repeat of the drawings above.

"Arabidopsis thaliana sl10" by Stefan.lefnaer — https://commons.wikimedia.org/wiki/File:Arabidopsis_thaliana_sl10.jpg — CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/); modified: resized from 3,096 x 4,128 to 1,050 x 1,400 pixels and saved as WebP

The two photographs on this page show the difference. On the weed at the top, stems leave the base at irregular angles and fork again only a few times, while the drawn weed branches on each segment at each step.

To try the rule yourself, a pencil and a sheet of paper are enough. Rewrite F twice by hand, draw the 25 segments with a fixed angle, and compare the result with the two photographs on this page.

Other pages follow branching in real bodies. Crown shyness is about treetops that leave gaps between them, and Leonardo's tree rule is a rule for how thick real branches are.

Sources

  1. Prusinkiewicz P, Lindenmayer A (1990). The Algorithmic Beauty of Plants. New York: Springer-Verlag; authors' electronic edition 2004, chapter 1 (Graphical modeling using L-systems) and preface. Fig. 1.24, p. 25. algorithmicbotany.org/papers/abop/abop-ch1.pdfRead: full text; preface p. vi, chapter 1 pp. 3, 24 and 25 (Fig. 1.24 checked on the page image)

Cite this page

Spiral, Fern & Honeycomb. “L-System Plants: One Rewrite Rule Draws a Branching Weed.” Published November 23, 2026. https://spiralfernandhoneycomb.com/branching/l-system/ (accessed the day you read it).