HomeArticlesFractal Tree

Fractal Trees: Recursion, Branching and the Golden Angle

Grow a tree from one recursive rule — depth, ratio and spread — and see the golden angle and L-systems explain why real plants branch the way they do.

mysimulator teamUpdated June 2026≈ 6 min read▶ Open the simulation

A tree is a rule applied to itself

A fractal tree is built from a single idea, repeated: draw a branch, then draw two (or more) smaller branches from its tip, each rotated by some angle, then repeat that same step on every one of those new branches. This is recursion — a function that calls itself with a smaller version of the problem — and it is a remarkably good match for how real plants actually grow, because a growing shoot does not know or care how many branching generations came before it; it just follows the same local growth rule its parent branch followed.

function branch(length, angle):
    draw a line of this length at this angle
    if length > minimum:
        branch(length * ratio, angle - spread)   // left child
        branch(length * ratio, angle + spread)   // right child
live demo · a recursive branching tree, swaying in wind● LIVE

Each call to branch() shrinks the length by a fixed ratio (commonly around 0.6 to 0.75) and rotates by a spread angle before spawning its own children. Three numbers — depth, ratio and spread — control the entire silhouette: shallow depth gives a sparse sapling, high depth gives a dense, leafy crown; a wide spread gives a broad, bushy shape, a narrow spread gives a tall, columnar one. This kind of self-referential rule for generating branching structures is formally called an L-system (Lindenmayer system), named after biologist Aristid Lindenmayer, who introduced them in 1968 specifically to model how algae and plants grow cell by cell.

Why plants actually branch this way

Real trees are not literally running a recursive function, but the resemblance is not a coincidence. A growing tip (the meristem) responds to the same few local signals no matter how many branching generations preceded it — available light, gravity, and chemical growth hormones called auxins — and it has no way to know the tree's overall shape or history. Because every tip follows the same local rule, the emergent whole ends up self-similar: a small branch, viewed alone, looks statistically like a miniature version of the whole tree. This is exactly the recursive, scale-free property that mathematicians call a fractal.

The golden angle shows up in nature, not just in code

Many real plants space their leaves, seeds or branches around the stem by a very specific rotation: the golden angle, approximately 137.5°, derived from the golden ratio φ ≈ 1.618. Rotating by this exact irrational angle at each new growth point is the most efficient way to pack leaves around a stem without ever exactly overlapping a previous one, which is why it keeps recurring independently across unrelated plant families — sunflower seed heads, pinecone scales, and the spiral arrangement of leaves on many stems (a field of study called phyllotaxis). It is a striking case of the same simple recursive-rotation rule appearing over and over in nature because it happens to solve a real packing problem well.

golden angle  =  360° × (1 − 1/φ)  ≈  137.507764°
where φ (phi) = (1 + √5) / 2 ≈ 1.618033989

Adding wind: turning a static fractal into a simulation

A purely recursive tree is static geometry. To make it sway, the simulation on this page perturbs the angle parameter at every branch over time using a smooth periodic function (layered sine waves at different frequencies, sometimes called procedural noise), with the perturbation amplitude scaled down toward the trunk and up toward the tips — mimicking how a real tree's thick trunk barely moves while its thin outer twigs whip around in a breeze. Because each branch's motion is computed relative to its parent's already-swaying position, small oscillations at the base compound into much larger, more chaotic-looking motion at the leaf tips, the same way a whip's handle moves gently while its tip cracks.

Frequently asked questions

What happens if you increase the recursion depth too far?

The tree gets exponentially more detailed and slower to draw, because the number of branches roughly doubles with every additional level of depth (for a simple two-child rule). Past a certain depth the branches also become shorter than a single pixel, adding visual density without adding any real new information.

Why do some fractal trees look more realistic than others?

Realism mostly comes from varying the ratio, spread and even the number of child branches slightly at each split rather than using perfectly identical values everywhere. Real plants have irregularities from uneven light, damage and genetics, so a small amount of randomness in each parameter goes a long way toward avoiding an obviously synthetic, perfectly symmetric look.

Is the golden angle the only spacing angle plants use?

No, but it is unusually common because it is the irrational angle that is hardest to approximate with any simple fraction, which minimises exact overlap between successive leaves or seeds as they spiral outward. Some plants use other, simpler angular spacings, especially when leaves are not added continuously but in whorls or pairs.

Try it live

Everything above runs in your browser — open Fractal Tree and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Fractal Tree simulation

What did you find?

Add reproduction steps (optional)