The Pythagoras Tree Fractal

A fractal built from nothing but squares and right triangles, in which every branch is the picture of the Pythagorean theorem. Watch it grow, see why each level has exactly the same area, and draw your own.

By the PythagoreanTheorem.net teamUpdated 7 min read

The Pythagoras tree is a fractal made of squares. Start with one square, stand a right triangle on its top side, build a square on each of the triangle's two shorter sides, and repeat on every new square forever. Each step is the familiar picture of the Pythagorean theorem. The Dutch mathematics teacher Albert E. Bosman invented it in 1942.

A fractal is a shape that contains smaller copies of itself: zoom in on any branch of the tree and you find a whole tree. Because every branch is built with the theorem a2 + b2 = c2, the tree also has a surprising property that you can prove in one line.

How the Pythagoras tree is built

Look at the classic diagram of the Pythagorean theorem, with a square on each side of a right triangle, and turn it upside down. The square on the hypotenuse becomes a trunk, and the squares on the two legs become branches.

c²b²a² c
One step of the tree: a right triangle stands on the top of the trunk square, and squares grow on its legs. Their areas, a2 and b2, add up to the trunk's area c2.
  1. Draw a square. This is the trunk, level 0.
  2. Add a right triangle on top. Its hypotenuse is the top side of the square, and its right angle points up.
  3. Build a square on each leg of the triangle, facing outward. These two squares are level 1.
  4. Repeat steps 2 and 3 on the top side of every new square, using the same shape of triangle each time.

In the classic, symmetric tree the triangle is a 45-45-90 triangle. Its legs are 1/√2 ≈ 0.707 times its hypotenuse, so each new square has a side about 70.7% of its parent's. After two levels the squares are exactly half the trunk's width, and they stand upright again, parallel to the trunk.

Watch the Pythagoras tree grow

Each level doubles the number of squares. The animation below grows the symmetric tree level by level, from the trunk up to level 8, which alone has 256 squares.

The symmetric Pythagoras tree growing from its trunk to level 8: 511 squares in all. Deeper levels overlap their neighbors.
LevelSquaresSide of eachArea of eachTotal area
01111
12≈ 0.70711/21
240.51/41
38≈ 0.35361/81
4160.251/161
82560.06251/2561
n2n(1/√2)n1/2n1

The table assumes a trunk of side 1; sides are rounded to four decimal places. Levels 0 through n contain 2n + 1 − 1 squares, so the nine levels in the animation hold 29 − 1 = 511. The squares shrink quickly but never vanish, and the tree keeps branching forever.

Two things happen as the tree grows. First, branches start to collide. At level 4, two squares on either side of the center line meet edge to edge, and from level 5 on, new squares overlap squares that are already there. Second, the tree stays in a fixed region: a computer calculation of the corners shows that with a trunk of side 1, the complete infinite tree fits inside a rectangle 6 units wide and 4 units tall, trunk included.

Why every level has the same area

The last column of the table is always 1. That is no accident of the 45° angle; it is the Pythagorean theorem at work, and it holds for every Pythagoras tree. Take any square in the tree, with side c. The right triangle on top of it has hypotenuse c and legs a and b, and the two child squares have areas a2 and b2. By the theorem,

a2 + b2 = c2

So every square passes on exactly its own area to its two children. Apply this to every square in level n at once: level n + 1 has the same total area as level n. By induction, every level has the same total area as the trunk.

1½¼⅛⅛¼⅛⅛½¼⅛⅛¼⅛⅛Level 38 × ⅛= 1Level 24 × ¼= 1Level 12 × ½= 1Level 01 × 1= 1Each level:total 1
With a trunk of area 1, each level of the symmetric tree has total area 1: twice as many squares, each half as big.

For the symmetric tree you can see it directly: level n has 2n squares of area 1/2n each. For a general tree with angle θ at the left end of the triangle, the children have sides ccosθ and csinθ, and c2cos2θ + c2sin2θ = c2 because cos2θ + sin2θ = 1, which is the Pythagorean identity.

A puzzleIf every level has area 1, then levels 0 to n together have area n + 1, which grows without limit. Yet the whole tree fits in a 6-by-4 rectangle of area 24. The resolution is the overlapping: from level 5 on, squares sit on top of one another, so adding up their areas counts some regions many times.

The same idea, keeping the areas but changing the shapes, is what the page on the Pythagorean theorem for other shapes explores: semicircles or equilateral triangles on the sides of a right triangle obey the same rule.

Lopsided trees: other angles

Nothing forces the triangle to be isosceles. Any right triangle works, and different angles give trees with very different personalities. With angle θ at the left end, the left child has side cosθ times its parent's and the right child sinθ times. The bigger child is always on the same side, so the tree leans and curls toward it.

3-4-5 angles (36.87°)children ⅘ and ⅗ of the parent30-60-90 angleschildren 0.87 and 0.5 of the parent
Two lopsided trees, drawn until the squares become too small to see. Left: triangles with the angles of a 3-4-5 triangle. Right: triangles with the angles of a 30-60-90 triangle, which curls into a tighter spiral.
  • 3-4-5 angles (θ ≈ 36.87°): the children have sides 4 over 5 and 3 over 5 of their parent and areas 16 over 25 and 9 over 25, which add up to 1, the 3-4-5 triangle in fractal form.
  • 30-60-90 angles (θ = 30°): the children have sides √3 over 2 ≈ 0.866 and 1 over 2 of their parent and areas 3 over 4 and 1 over 4. See the 30-60-90 triangle.
  • Smaller angles make the big child almost as large as its parent and the small child tiny, so the tree becomes one long curling spiral with small side shoots, a little like the spiral of Theodorus.

Whatever the angle, the area rule still holds: every level of every Pythagoras tree has the same total area as the trunk.

How to draw or code a Pythagoras tree

By hand, a ruler, a set square and a compass are enough for the first four or five levels of the symmetric tree; after that the squares get too small. With a computer you can go much deeper. The whole tree is one short recursive function: a function that draws a square and then calls itself twice, once for each child. Here it is in pseudo-code, using coordinates in which y points up:

function tree(P, Q, levels):
    # P, Q = bottom-left and bottom-right corners of a square
    if levels == 0: return
    v = Q - P                     # the bottom side, as a vector
    n = (-v.y, v.x)               # v turned 90° counterclockwise
    S = P + n                     # top-left corner
    R = Q + n                     # top-right corner
    draw polygon P, Q, R, S
    T = S + cos(θ) * (cos(θ) * v + sin(θ) * n)   # apex of the triangle
    tree(S, T, levels - 1)        # square on the left leg
    tree(T, R, levels - 1)        # square on the right leg

θ = 45°
tree((0, 0), (1, 0), 9)           # trunk plus 8 levels: 511 squares

The apex T is the right-angle corner of the triangle: it lies at distance cosθ times the side length from S, at angle θ above the top side. On a screen, where y usually points down, either flip the drawing or use n = (vy, −vx) instead. Every tree on this page was drawn with this function, with θ = 45°, 36.87° or 30°.

Try thisChange one line at a time: alternate the angle between levels, color each level differently, or stop drawing a branch when its square gets smaller than a pixel. Coding the tree is a good first project in recursion, and the computing and games page shows other ways programmers use the theorem.

Frequently asked questions

Who invented the Pythagoras tree?

Albert E. Bosman, a Dutch mathematics teacher, in 1942. It is named after Pythagoras because each branch repeats the standard diagram of the Pythagorean theorem: squares on the three sides of a right triangle.

What is the area of each level of a Pythagoras tree?

Exactly the area of the trunk, at every level. Each square's two children have areas a2 and b2, which add up to the parent's area c2 by the Pythagorean theorem, so no level ever gains or loses area.

How many squares are in a Pythagoras tree?

Level n has 2n squares, and the trunk plus n levels have 2n + 1 − 1 altogether. The mathematical fractal has infinitely many levels, so infinitely many squares.

How big is the Pythagoras tree?

For the symmetric tree with a trunk of side 1, the complete infinite tree fits in a rectangle 6 units wide and 4 units tall. It never grows beyond that, even though it has infinitely many branches.

Does the Pythagoras tree have to be symmetric?

No. Any right triangle can be used. Unequal angles make one child bigger than the other, and the tree leans and curls toward the bigger side. Every version keeps the property that each level has the same total area.

Sources and further reading

  1. Heinz-Otto Peitgen, Hartmut Jürgens and Dietmar Saupe, Chaos and Fractals: New Frontiers of Science (Springer, 1992), on Pythagorean trees and other self-similar figures.
  2. "Pythagoras tree (fractal)", Wikipedia.

Keep exploring