A fractal built from a right triangle
The Pythagoras tree is a plane fractal invented by Dutch mathematics teacher Albert E. Bosman in 1942. It starts from a single square. On top of that square, a right triangle is erected whose hypotenuse is exactly the square's top edge; two new, smaller squares are then built on the triangle's other two sides. Repeat that same construction on each new square, forever, and you get a tree-like branching fractal — and it is called the Pythagoras tree because the areas of the two child squares always add up to exactly the area of the parent square, which is simply the Pythagorean theorem, a² + b² = c², read as a statement about squares built on a triangle's sides rather than just their lengths.
The recursion, step by step
If the right angle of the triangle sits at a fraction of the way along the base square's top edge (controlled by an angle parameter), the two child squares end up different sizes — a smaller one and a larger one — which is exactly what gives the classic Pythagoras tree its asymmetric, wind-blown look rather than a perfectly symmetric one. At 45°, the two child squares are equal, and the fractal grows as a symmetric double spiral instead.
grow(square, depth):
if depth == 0: return
triangle = right_triangle_on_top_edge(square, angle)
left_sq = square_on_side(triangle, side="left")
right_sq = square_on_side(triangle, side="right")
draw(square)
grow(left_sq, depth - 1)
grow(right_sq, depth - 1)
Because both child squares shrink relative to the parent (each side length is scaled by the sine and cosine of the tree's angle), the total area contributed at each depth level shrinks geometrically. That means the infinite tree — depth going to infinity — still covers only a finite total area, a hallmark shared by many classic fractals: infinite detail packed into a bounded region. At around 45°, that limiting area works out to exactly twice the area of the starting square, one of the tidier results in recreational fractal geometry.
Depth, leaning and why it looks organic
Depth controls how many recursive levels are drawn — each extra level roughly doubles the number of squares on screen, so depth 10 already means over a thousand new squares at the finest level alone, which is why most implementations cap depth somewhere around 12–14 before the squares become smaller than a pixel and adding more no longer changes the picture. A small amount of random jitter added to the angle at each recursive call — a common embellishment beyond Bosman's original strict construction — is what makes generated Pythagoras trees look like real branching plants instead of a rigid, mechanically repeated shape; real trees, ferns and river deltas all show this same kind of statistical self-similarity, where each branch resembles the whole but never exactly.
Frequently asked questions
Why is it called the Pythagoras tree?
Each step of the construction builds a right triangle with a square on each of its three sides, and by the Pythagorean theorem the areas of the two smaller squares always add up exactly to the area of the larger square, the same relationship a² + b² = c² describes for the side lengths.
Does the tree ever stop growing?
Mathematically the construction can continue forever, adding infinitely many squares, but because each generation's squares are smaller by a fixed ratio, the total area covered converges to a finite number rather than growing without bound — at a 45° angle, that limit is exactly twice the area of the very first square.
Why does changing the angle slider change the tree's shape so much?
The angle decides where the right angle of each recursive triangle sits along the parent square's top edge. An angle of 45° gives two equal child squares and a symmetric double-spiral tree; moving away from 45° makes one child square larger than the other, producing the lopsided, wind-blown look of the classic Pythagoras tree.
Try it live
Everything above runs in your browser — open Pythagoras Tree and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Pythagoras Tree simulation