Skip to content
The Lumenary
Grades 3–5Ages 8–11 40 min

Area, perimeter and angles

How much ground a shape covers, how far it is around it, and how much you turn at each corner — three different questions with three different answers.

Formally verified · 12 LeanComputationally tested · 2 PythonAI-drafted · awaiting human reviewMathematically reviewed: Awaiting human review

Your guides: Chloe, Margaret, Gideon

MotivationH

A fence, a floor and a turn

Kofi lives on a farm in Ghana. He has 24 metres of fence to make a rectangular pen for his goats. He could make it long and thin, or short and wide. Does it matter? The fence is the same length either way — but will the goats get the same amount of grass?

In a school in Lima, Ana's class is covering their classroom floor, 8 metres long and 6 metres wide, with square mats, each one metre long and one metre wide. How many mats do they need?

And when you ride a bicycle round a corner, you turn. Turn all the way round and you are facing where you started. How can we measure how much you turned?

These are three different questions: how far around (perimeter), how much surface (area), and how much turn (angle). This lesson is about all three — and about not mixing them up.

IntuitionH

Covering, walking round, turning

Area is about covering. Lay down square tiles, all the same size, with no gaps and no overlaps. The number of tiles you need is the area.

Perimeter is about walking round the edge. Walk all the way round a shape and measure how far you went.

Here is a rectangle drawn as rows of unit squares. Change the width and the height. Count the squares, then press "Trace the perimeter" to walk round it.

Rows times columns

Area counts the unit squares inside a shape; perimeter measures the distance around it.

64

4 rows of 6 squares: multiply to count them all.

Area

6 × 4 = 24

24 m²

Area is counted in unit squares. Perimeter is counted in unit lengths, all the way around the edge.

DefinitionsH

Words we need

Definition— area

The area of a shape is the amount of surface it covers. We measure it by counting unit squares: squares 1 unit long and 1 unit wide. A square 1 centimetre on each side has an area of 1 square centimetre, written 1 cm21\text{ cm}^2. A square 1 metre on each side has area 1 m21\text{ m}^2.

Definition— perimeter

The perimeter of a shape is the total length of its boundary — the distance all the way round. It is a length, so it is measured in units of length such as centimetres (cm) or metres (m).

Definition— angle

An angle is the amount of turn between two rays (arms) that start at the same point, the vertex. We measure angles in degrees: one full turn is 360∘360^\circ.

So a half turn is 180∘180^\circ (a straight angle) and a quarter turn is 90∘90^\circ (a right angle, like the corner of a book). An angle smaller than a right angle is acute; an angle between a right angle and a straight angle is obtuse; an angle bigger than a straight angle is reflex.

quarter turn: 90°half turn: 180°full turn: 360°
A quarter turn is 90°, a half turn is 180°, and a full turn is 360°. A small square marks a right angle.

Definition— volume

The volume of a solid is the amount of space it takes up. We measure it by counting unit cubes, for example cubes 1 cm on each edge, each of volume 1 cm31\text{ cm}^3.

Worked examplesH

Worked examples

Example— A rectangle

A rectangle is 7 cm long and 3 cm wide.

  • Area: 3 rows of 7 unit squares: 3×7=21 cm23 \times 7 = 21\text{ cm}^2.
  • Perimeter: 7+3+7+3=20 cm7 + 3 + 7 + 3 = 20\text{ cm}, which is also 2×(7+3)2 \times (7 + 3).

Example— Ana's classroom

The floor is 8 m long and 6 m wide. The mats make 6 rows of 8, so the class needs 6×8=486 \times 8 = 48 mats: the area of the floor is 48 m248\text{ m}^2. A ribbon round the edge of the floor would be 8+6+8+6=288 + 6 + 8 + 6 = 28 m long.

Example— An L-shaped room

A room is shaped like an L: a 5 m by 4 m rectangle with a 2 m by 2 m square missing from one corner.

  • Area by subtracting: 5×4−2×2=20−4=16 m25 \times 4 - 2 \times 2 = 20 - 4 = 16\text{ m}^2.
  • Area by splitting: cut the L into a 5 m by 2 m strip and a 3 m by 2 m strip: 10+6=16 m210 + 6 = 16\text{ m}^2. Two different methods, the same answer — a good check.
  • Perimeter: walk round the six walls: 5+2+2+2+3+4=18 m5 + 2 + 2 + 2 + 3 + 4 = 18\text{ m}. A wall you cannot see on the plan still has a length: work it out from the others.

Example— Units matter

A side is a length, so it is in cm. An area counts squares, so it is in cm2\text{cm}^2. Writing "the area is 21 cm" is like saying "I have 21" without saying 21 what. Always say which unit you are counting.

ExplanationH

Same area, different perimeter — and the other way round

Back to Kofi and his 24 metres of fence. Here are some rectangles with whole-metre sides he could make:

PenPerimeterArea
1 m by 11 m24 m11 m211\text{ m}^2
2 m by 10 m24 m20 m220\text{ m}^2
4 m by 8 m24 m32 m232\text{ m}^2
6 m by 6 m24 m36 m236\text{ m}^2

Same fence, very different amounts of grass! The long thin pen gives the goats less than a third of the square pen. Shapes with the same perimeter can have different areas.

It works the other way too. All these rectangles have area 24 m224\text{ m}^2: 1 by 24 (perimeter 50 m), 2 by 12 (28 m), 3 by 8 (22 m), 4 by 6 (20 m). Shapes with the same area can have different perimeters.

Try it yourself: make three different shapes with an area of 12 squares, record each one, and compare their perimeters.

Area and perimeter

Make three different shapes with an area of 12 squares. Record each one. Which has the longest perimeter? The shortest?

Click or tap squares to fill or empty them (with a mouse you can also drag). Arrow keys move between squares.

Start by filling in a few squares.

ProofH

Why the rules work

Theorem— Area of a rectangle

A rectangle that is ww units wide and hh units high has area w×hw \times h square units.

Proof

Cover the rectangle with unit squares. Each row holds ww squares, and there are hh rows (one for each unit of height). So there are w+w+⋯+ww + w + \dots + w (hh times) =h×w= h \times w squares. Because h×w=w×hh \times w = w \times h, it does not matter whether we count by rows or by columns.

∎

Theorem— Angles of a triangle

The three angles of any triangle drawn on a flat surface add up to 180∘180^\circ.

First an experiment you can do with paper and scissors: cut out a triangle — any triangle — and tear off its three corners. Put the corners together, points touching. They fit together into a straight line: a half turn, 180∘180^\circ. Try it with a long thin triangle and a fat one. It always works. But trying triangles is not a proof: here is why it must work.

abdecABC
The line through the top corner is parallel to the base. The angle marked d is equal to a, and e is equal to b (they make Z-shapes with the parallel lines). And d, c and e together make a straight line.

Proof

Call the angles of the triangle aa, bb and cc, as in the picture. Through the top corner, draw the line parallel to the base: it never meets the base, however far it goes.

  • Along the parallel line, the three angles dd, cc and ee fit together into a straight line, so d+c+e=180∘d + c + e = 180^\circ.
  • The angle dd and the angle aa form a "Z" with the two parallel lines. Such alternate angles are equal: d=ad = a. In the same way, e=be = b.

So a+b+c=d+e+c=180∘a + b + c = d + e + c = 180^\circ.

∎

Note

The fact that alternate angles at parallel lines are equal is one of the basic properties of a flat surface. On a curved surface, such as a globe, it fails — and so does the 180∘180^\circ rule (see the viewpoints below).

The 180∘180^\circ rule has some quick consequences:

  • A triangle cannot have two right angles. 90∘+90∘=180∘90^\circ + 90^\circ = 180^\circ already, which would leave 0∘0^\circ for the third angle.
  • A triangle has at most one obtuse angle, for the same reason.
  • If all three angles are equal, each is 60∘60^\circ, because 180÷3=60180 \div 3 = 60.
  • The angles of a quadrilateral add up to 360∘360^\circ. Cut it along a diagonal into two triangles: 180∘+180∘=360∘180^\circ + 180^\circ = 360^\circ.

Theorem— Vertically opposite angles

Where two straight lines cross, the angles opposite each other are equal.

Proof

Call the angles going round the crossing point aa, bb, cc. The angles aa and bb together make a straight line, so a+b=180∘a + b = 180^\circ. The angles bb and cc also make a straight line, so b+c=180∘b + c = 180^\circ. Both aa and cc are "180∘180^\circ take away bb", so a=ca = c.

∎

ExplanationH

Measuring and drawing angles

A protractor is a half circle marked from 0∘0^\circ to 180∘180^\circ. To measure an angle, put the centre of the protractor on the vertex, line up the 0∘0^\circ mark with one arm, and read where the other arm crosses the scale.

030609012015018050°
Measuring an angle: the centre of the protractor sits on the vertex, the 0° line lies along one arm, and the other arm crosses the scale at 50°.

To draw an angle of, say, 50∘50^\circ: draw one arm, put the protractor's centre on its end with 0∘0^\circ along the arm, make a dot at the 50∘50^\circ mark, and join the vertex to the dot.

The size of an angle is the amount of turn from one arm to the other. It does not depend on how long the arms are drawn:

40°40°
These two angles are the same size, 40°. The arms on the right are longer, but the amount of turn between them is exactly the same.
Explore

Sorting triangles and quadrilaterals

We can sort triangles by their sides:

  • equilateral: all three sides equal;
  • isosceles: at least two sides equal;
  • scalene: no two sides equal;

and by their angles:

  • acute: all three angles are acute;
  • right: one angle is a right angle;
  • obtuse: one angle is obtuse.

Quadrilaterals have names too: square, rectangle, rhombus, parallelogram, trapezium (called a trapezoid in the USA) and kite. Every square is also a rectangle (four right angles) and also a rhombus (four equal sides).

Switch on "angles" and "sides" in the explorer, and sort each shape. Which triangle is right and isosceles? Do the angles of every triangle add up to 180∘180^\circ? Of every quadrilateral to 360∘360^\circ?

Sort by sides and angles

Pick a shape and switch on its features: sides, corners, angles, symmetry and diagonals.

60°60°60°

Equilateral triangleTriangle

Sides
3
Angles
60°, 60°, 60°
Angle sum
180°

All three sides are equal and all three angles are 60°.

Sides with the same number of ticks are equal.

The second mode of the explorer cuts any polygon into triangles from one corner. A quadrilateral makes 2 triangles (2×180∘=360∘2 \times 180^\circ = 360^\circ), a pentagon makes 3. Try more sides: can you predict the angle sum before you look?

Angle sums by cutting into triangles

Pick a shape and switch on its features: sides, corners, angles, symmetry and diagonals.

1290°90°90°90°A

Regular quadrilateral

From vertex A, 1 diagonals cut the quadrilateral into 2 triangles.

The angles of each triangle add up to 180°, and together they make up exactly the angles of the polygon. So the angle sum is

(4 − 2) × 180° = 360°

Each angle of the regular quadrilateral: 360° ÷ 4 = 90°

This works for every convex polygon, regular or not: try Irregular.

ExplanationH

Volume: counting cubes

A box can be filled with unit cubes in layers. The box below is 4 cubes long and 3 cubes deep, so one layer holds 4×3=124 \times 3 = 12 cubes. It is 2 layers high, so it holds 12×2=2412 \times 2 = 24 cubes.

4 long2 high3 deep
A box 4 cubes long, 3 cubes deep and 2 cubes high. Each layer is a 4 × 3 rectangle of 12 cubes; two layers make 24 cubes.

Theorem— Volume of a box

A box ℓ\ell units long, ww units wide and hh units high has volume ℓ×w×h\ell \times w \times h cubic units.

Proof

Each layer is a rectangle of ℓ×w\ell \times w cubes (by the area rule), and there are hh layers, so there are ℓ×w×h\ell \times w \times h cubes.

∎

Formal mathematicsF

Gideon's true-or-false game

Gideon only plays with statements that are exactly true or exactly false. Decide, and give a reason.

  1. "A rectangle 3 cm by 4 cm and a rectangle 2 cm by 6 cm have the same area." — True. Both are 12 cm212\text{ cm}^2.
  2. "…so they also have the same perimeter." — False. 14 cm and 16 cm. One counterexample is enough to break "same area means same perimeter".
  3. "Some triangle has two right angles." — False. Its angles would already add up to 180∘180^\circ before the third one.
  4. "An angle with longer arms is bigger." — False. The size of an angle is the amount of turn, not the length of the arms.
For grown-ups · the same ideas in Lean, a proof checker

In Lean, a shape on squared paper is a list of unit squares, each named by its column and row. A w × h rectangle is built one column at a time, and Lean proves the area rule for every width and height by adding one column at a time:

rectLean 4Formally verified
/-- A rectangle `w` squares wide and `h` squares high, built one column at a time. -/
def rect : Nat → Nat → Shape
  | 0, _ => []
  | w + 1, h => column w h ++ rect w h
Axioms used: No axiomsformal/Lumenary/AreaAngles.leanTry it in the Lean web editor
area_rectLean 4Proved here from basic factsFormally verified
/-- **The area of a rectangle is width × height.** Each column holds `h` squares, and there
are `w` columns, so there are `h + h + ⋯ + h = w × h` squares. The proof adds one column at a
time (induction on the width). -/
theorem area_rect (w h : Nat) : area (rect w h) = w * h := by
  induction w with
  | zero => simp [rect, area]
  | succ w ih =>
    simp only [area] at ih ⊢
    simp only [rect, List.length_append, column, List.length_map, List.length_range, ih]
    rw [Nat.succ_mul]
    omega
Axioms used: propext, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor

The perimeter counts, for every square, its sides that face outside the shape. Lean computes areas and perimeters to check both "same area, different perimeter" and "same perimeter, different area", and checks the rule 2×(w+h)2 \times (w + h) for every rectangle up to 6×66 \times 6:

perimeterLean 4Formally verified
/-- The **perimeter** of a shape, in units: for every square, count those of its four sides
(right, left, top, bottom) whose neighbouring square is outside the shape. -/
def perimeter (s : Shape) : Nat :=
  (s.map fun p =>
    outside s (p.1 + 1, p.2) + outside s (p.1 - 1, p.2) +
    outside s (p.1, p.2 + 1) + outside s (p.1, p.2 - 1)).sum
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor
same_area_different_perimeterLean 4Proved here from basic factsFormally verified
/-- **Same area, different perimeters.** Rectangles `3 × 4`, `2 × 6` and `1 × 12` all have
area 12, but their perimeters are 14, 16 and 26. Lean counts the squares and the sides. -/
theorem same_area_different_perimeter :
    area (rect 3 4) = 12 ∧ area (rect 2 6) = 12 ∧ area (rect 1 12) = 12 ∧
    perimeter (rect 3 4) = 14 ∧ perimeter (rect 2 6) = 16 ∧ perimeter (rect 1 12) = 26 := by
  decide
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor
same_perimeter_different_areaLean 4Proved here from basic factsFormally verified
/-- **Same perimeter, different areas.** Rectangles `3 × 3`, `2 × 4` and `1 × 5` all have
perimeter 12, but their areas are 9, 8 and 5. -/
theorem same_perimeter_different_area :
    perimeter (rect 3 3) = 12 ∧ perimeter (rect 2 4) = 12 ∧ perimeter (rect 1 5) = 12 ∧
    area (rect 3 3) = 9 ∧ area (rect 2 4) = 8 ∧ area (rect 1 5) = 5 := by
  decide
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor
perimeter_rect_smallLean 4Proved here from basic factsFormally verified
/-- Walking round a rectangle gives `w + h + w + h = 2 × (w + h)`. Here Lean checks that
counting the outside sides square by square agrees with this rule for **every** rectangle up to
`6 × 6` — 36 rectangles, checked one by one. -/
theorem perimeter_rect_small :
    ∀ w < 6, ∀ h < 6, perimeter (rect (w + 1) (h + 1)) = 2 * ((w + 1) + (h + 1)) := by
  decide
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor

Volume, layer by layer, for every box:

volume_boxLean 4Proved here from basic factsFormally verified
/-- **The volume of a box is length × width × height.** Each layer is a rectangle of `l × w`
cubes (by `area_rect`), and there are `h` layers. -/
theorem volume_box (l w h : Nat) : (box l w h).length = l * w * h := by
  induction h with
  | zero => rfl
  | succ h ih =>
    have hl : (layer l w h).length = l * w := by
      simp only [layer, List.length_map]
      exact area_rect l w
    simp only [box, List.length_append, hl, ih]
    rw [Nat.mul_succ]
    omega
Axioms used: propext, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor

For angles, Lean does not draw lines or measure. Instead, the geometric facts the human proof uses — angles on a straight line make 180∘180^\circ, alternate angles are equal — are hypotheses, and Lean checks that the conclusions follow from them. The calc steps follow the human proof:

vertically_oppositeLean 4Proved here from basic factsFormally verified
/-- **Vertically opposite angles are equal.** Where two straight lines cross, angles `a` and `b`
sit side by side on one line, and `b` and `c` on the other; each pair makes a straight angle of
180°. So `a = 180° − b = c`. -/
theorem vertically_opposite (a b c : Nat) (h₁ : a + b = 180) (h₂ : b + c = 180) : a = c := by
  omega
Axioms used: propext, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor
triangle_angle_sumLean 4Proved here from basic factsFormally verified
/-- **The angles of a triangle add up to 180°.** Draw the line through the top corner parallel to
the base. At the top corner, three angles `d`, `c`, `e` lie along this line, so
`d + c + e = 180`. The angles `d` and `e` are alternate angles to the base angles `a` and `b`,
so `d = a` and `e = b`. The geometry is in the hypotheses; Lean checks the conclusion. -/
theorem triangle_angle_sum (a b c d e : Nat)
    (straight : d + c + e = 180) (alt₁ : d = a) (alt₂ : e = b) : a + b + c = 180 :=
  calc a + b + c = d + e + c := by rw [alt₁, alt₂]
    _ = d + c + e := by omega
    _ = 180 := straight
Axioms used: propext, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor
no_two_right_anglesLean 4Proved here from basic factsFormally verified
/-- A triangle cannot have two right angles: the third angle would have to be 0°. -/
theorem no_two_right_angles (a b c : Nat) (sum : a + b + c = 180) (hc : 0 < c) :
    ¬ (a = 90 ∧ b = 90) := by
  omega
Axioms used: propext, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor
at_most_one_obtuseLean 4Proved here from basic factsFormally verified
/-- A triangle has at most one obtuse angle (more than 90°): two of them would already add up
to more than 180°. -/
theorem at_most_one_obtuse (a b c : Nat) (sum : a + b + c = 180) : ¬ (90 < a ∧ 90 < b) := by
  omega
Axioms used: propext, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor
quadrilateral_angle_sumLean 4Proved here from basic factsFormally verified
/-- **The angles of a quadrilateral add up to 360°.** A diagonal cuts it into two triangles with
angles `a₁, b₁, c₁` and `a₂, b₂, c₂`. Two corners of the quadrilateral are split by the
diagonal (`q = b₁ + b₂`, `s = c₁ + c₂`); the other two are whole triangle angles. -/
theorem quadrilateral_angle_sum (a₁ b₁ c₁ a₂ b₂ c₂ p q r s : Nat)
    (t₁ : a₁ + b₁ + c₁ = 180) (t₂ : a₂ + b₂ + c₂ = 180)
    (hp : p = a₁) (hq : q = b₁ + b₂) (hr : r = a₂) (hs : s = c₁ + c₂) :
    p + q + r + s = 360 := by
  omega
Axioms used: propext, Quot.soundformal/Lumenary/AreaAngles.leanTry it in the Lean web editor

What is not formalised here: the geometry of the flat plane itself — parallel lines and why alternate angles are equal. Mathlib, Lean's large mathematics library, proves the angle sum of a triangle in Euclidean space from scratch (EuclideanGeometry.angle_add_angle_add_angle_eq_pi, with angles in radians: π\pi radians =180∘= 180^\circ).

ComputationC

Margaret checks every rectangle and measures many triangles

Same perimeter, different area: rectangles and pentominoesPythonExact computationExhaustive finite checkComputationally tested
"""Same perimeter, different area - and the other way round.

Kofi has 24 metres of fence for a rectangular goat pen with whole-metre
sides. The program lists every such rectangle and its area. Then it fixes
the area instead (24 square metres) and lists every perimeter. Finally it
builds every shape made of 5 unit squares joined edge to edge (counting
shapes as different if they cannot be slid onto each other) and counts their
perimeters by checking every side of every square.

Runs unchanged in the browser (Pyodide) using only the standard library.
"""

import textwrap
from collections import Counter

#: The four neighbours of a square: right, left, up, down.
STEPS = ((1, 0), (-1, 0), (0, 1), (0, -1))

def rectangles_with_perimeter(p):
    """All (width, height) with whole sides, width <= height, perimeter p."""
    if p % 2:
        return []
    half = p // 2
    return [(w, half - w) for w in range(1, half // 2 + 1)]

def rectangles_with_area(a):
    """All (width, height) with whole sides, width <= height, area a."""
    return [(w, a // w) for w in range(1, a + 1) if a % w == 0 and w * w <= a]

def perimeter(squares):
    """Count the sides of the squares that face outside the shape."""
    shape = set(squares)
    return sum((x + dx, y + dy) not in shape
               for x, y in shape for dx, dy in STEPS)

def normalise(squares):
    """Slide a shape so that its lowest-left corner is at (0, 0)."""
    min_x = min(x for x, _ in squares)
    min_y = min(y for _, y in squares)
    return frozenset((x - min_x, y - min_y) for x, y in squares)

def shapes_of_size(n):
    """All shapes of n unit squares joined edge to edge, up to sliding."""
    shapes = {normalise([(0, 0)])}
    for _ in range(n - 1):
        bigger = set()
        for shape in shapes:
            for x, y in shape:
                for dx, dy in STEPS:
                    new = (x + dx, y + dy)
                    if new not in shape:
                        bigger.add(normalise(shape | {new}))
        shapes = bigger
    return shapes

def main():
    print("Rectangles with perimeter 24 (whole-number sides):")
    for w, h in rectangles_with_perimeter(24):
        print(f"  {w:>2} x {h:<2} area {w * h:>2}")
    print("Same fence, different areas: the square 6 x 6 holds the most.")
    print()
    print("Rectangles with area 24:")
    for w, h in rectangles_with_area(24):
        print(f"  {w:>2} x {h:<2} perimeter {2 * (w + h):>2}")
    print("Same area, different perimeters.")
    print()
    pentominoes = shapes_of_size(5)
    counts = Counter(perimeter(s) for s in pentominoes)
    print(f"Shapes of 5 squares (up to sliding): {len(pentominoes)}")
    for p in sorted(counts):
        print(f"  perimeter {p}: {counts[p]} shapes")
    print("All have area 5, but not all have the same perimeter.")
    print()
    print(textwrap.fill(
        "Epistemic status: exact and exhaustive for these cases - every "
        "whole-number rectangle with perimeter 24 or area 24, and every "
        "shape of 5 squares, was checked. It shows that area and perimeter "
        "are different measures; it does not prove anything about other "
        "sizes or shapes with curved sides.",
        width=78,
    ))

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Why do some shapes of 5 squares have a shorter perimeter? Five separate squares have 5×4=205 \times 4 = 20 sides. Every time two squares are joined along a side, two sides disappear inside the shape. Most shapes of 5 squares have 4 joins, so their perimeter is 20−8=1220 - 8 = 12. The 8 shapes with perimeter 10 are all the same "P" shape, turned and flipped: its 2×22 \times 2 block gives it a 5th join, so its perimeter is 20−10=1020 - 10 = 10.

Measuring the angles of many trianglesPythonNumerical approximationExperimental evidenceComputationally tested
"""Measuring angles with a computer: triangles, quadrilaterals and long arms.

The program draws many random triangles with corners on a square grid and
measures each angle (in degrees) from the coordinates, the way a very
careful protractor would. It adds up the three angles of every triangle and
the four angles of random convex quadrilaterals. It also lengthens the arms
of an angle to show the angle does not change, and sorts the triangles into
acute, right and obtuse exactly, using whole-number arithmetic.

Runs unchanged in the browser (Pyodide) using only the standard library.
"""

import math
import random
import textwrap

def angle_at(corner, p, q):
    """The angle at `corner` between the arms towards p and q, in degrees."""
    ux, uy = p[0] - corner[0], p[1] - corner[1]
    vx, vy = q[0] - corner[0], q[1] - corner[1]
    cos = (ux * vx + uy * vy) / (math.hypot(ux, uy) * math.hypot(vx, vy))
    return math.degrees(math.acos(max(-1.0, min(1.0, cos))))

def triangle_angles(a, b, c):
    """The three angles of triangle abc, in degrees."""
    return angle_at(a, b, c), angle_at(b, c, a), angle_at(c, a, b)

def cross(o, p, q):
    """Twice the signed area of triangle opq (0 means the points line up)."""
    return (p[0] - o[0]) * (q[1] - o[1]) - (p[1] - o[1]) * (q[0] - o[0])

def is_convex(quad):
    """True if the corners go round a convex quadrilateral in order."""
    signs = [cross(quad[i], quad[(i + 1) % 4], quad[(i + 2) % 4])
             for i in range(4)]
    return all(s > 0 for s in signs) or all(s < 0 for s in signs)

def kind(a, b, c):
    """'acute', 'right' or 'obtuse', decided exactly with whole numbers.

    The angle at a corner is more than 90 degrees exactly when the dot
    product of its two arms is negative, and exactly 90 when it is zero.
    """
    dots = []
    for o, p, q in ((a, b, c), (b, c, a), (c, a, b)):
        dots.append((p[0] - o[0]) * (q[0] - o[0])
                    + (p[1] - o[1]) * (q[1] - o[1]))
    if min(dots) < 0:
        return "obtuse"
    return "right" if min(dots) == 0 else "acute"

def random_point(rng):
    """A random point on the 21 x 21 grid of whole-number points."""
    return (rng.randint(0, 20), rng.randint(0, 20))

def random_triangles(rng, n):
    """n random triangles whose corners do not lie on one line."""
    out = []
    while len(out) < n:
        a, b, c = (random_point(rng) for _ in range(3))
        if cross(a, b, c) != 0:
            out.append((a, b, c))
    return out

def random_convex_quads(rng, n):
    """n random convex quadrilaterals with corners in order."""
    out = []
    while len(out) < n:
        quad = [random_point(rng) for _ in range(4)]
        if is_convex(quad):
            out.append(quad)
    return out

def main():
    rng = random.Random(2024)
    triangles = random_triangles(rng, 1000)
    sums = [sum(triangle_angles(*t)) for t in triangles]
    print("Three of the 1000 random triangles:")
    for t in triangles[:3]:
        angles = triangle_angles(*t)
        shown = " + ".join(f"{x:5.1f}" for x in angles)
        print(f"  corners {t}: {shown} = {sum(angles):.1f}")
    worst = max(abs(s - 180) for s in sums)
    print(f"All 1000 sums lie within {worst:.1e} degrees of 180.")
    kinds = [kind(*t) for t in triangles]
    print("Sorted exactly: " + ", ".join(
        f"{k} {kinds.count(k)}" for k in ("acute", "right", "obtuse")))
    print()
    quads = random_convex_quads(rng, 300)
    q_sums = [sum(angle_at(q[i], q[i - 1], q[(i + 1) % 4]) for i in range(4))
              for q in quads]
    worst_q = max(abs(s - 360) for s in q_sums)
    print(f"300 convex quadrilaterals: sums within {worst_q:.1e} of 360.")
    print()
    print("Longer arms, same angle (corner at (0, 0)):")
    for k in (1, 2, 10, 100):
        a = angle_at((0, 0), (3 * k, 1 * k), (1 * k, 2 * k))
        print(f"  arms {k:>3} times as long: {a:.6f} degrees")
    print()
    print(textwrap.fill(
        "Epistemic status: numerical evidence. Each angle is computed in "
        "floating-point arithmetic, so sums are off by tiny rounding errors; "
        "1300 shapes are not all shapes. The sorting into acute, right and "
        "obtuse is exact. Why every flat triangle has angle sum 180 degrees "
        "is explained by the proof in the lesson, not by this program.",
        width=78,
    ))

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

The sums are not exactly 180 in the computer: it rounds every number it works with, so tiny errors like 0.000000000001∘0.000000000001^\circ creep in. That is why this is numerical evidence, not a proof — and 1000 triangles are not all triangles. The proof above covers every triangle at once. (Did you notice how many of the random triangles were obtuse? Long thin triangles are very common!)

Exercises

Your turn

Have squared paper and a ruler ready. You can ask for a hint whenever you like.

1. Area, perimeter and angles

Warm-upHuman

A rectangular rug is 7 m long and 4 m wide. What is its area, in square metres?

2. Area, perimeter and angles

CoreHuman

A garden is a 6 m by 4 m rectangle with a 2 m by 2 m square cut out of one corner (for a shed). What is the area of the garden, in square metres?

3. Area, perimeter and angles

StretchHuman

The same garden: a 6 m by 4 m rectangle with a 2 m by 2 m square cut out of one corner. What is its perimeter, in metres? (Careful — it may surprise you!)

4. Area, perimeter and angles

CoreHuman

Kofi has 20 m of fence for a rectangular pen. Which pen gives his goats the most grass?

Choose one

5. Area, perimeter and angles

CoreHuman

Two angles of a triangle are 47° and 68°. How many degrees is the third angle?

6. Area, perimeter and angles

CoreHuman

A triangle has angles 90°, 45° and 45°. Which words describe it? Select all that apply.

Choose all that apply

7. Area, perimeter and angles

Warm-upHuman

Musa draws two angles. Both open exactly as wide as the corner of a book. The first has arms 2 cm long; the second has arms 10 cm long. Which angle is bigger?

Choose one

8. Area, perimeter and angles

CoreHuman

A box is 5 cm long, 3 cm wide and 4 cm high. How many 1 cm cubes fit exactly inside it? (This is its volume in cm3\text{cm}^3.)

9. Area, perimeter and angles

StretchFormal

In Lean, triangle_angle_sum has the hypotheses straight : d + c + e = 180, alt₁ : d = a and alt₂ : e = b, and concludes a + b + c = 180. Which sentence describes what Lean has checked?

Choose one

10. Area, perimeter and angles

StretchComputational

Complete the two functions so that area(w, h) returns the area and perimeter(w, h) returns the perimeter of a rectangle w units wide and h units high. The tests then check Kofi's pens.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
Common misconceptionsH

Things that trip people up

Misconception

Mixing up area and perimeter. Area counts the squares inside (square units); perimeter measures the distance around (units of length). A 3 by 4 rectangle has area 12 cm212\text{ cm}^2 but perimeter 14 cm.

Misconception

"Shapes with the same perimeter have the same area." Kofi's pens all use 24 m of fence, but their areas range from 11 m211\text{ m}^2 to 36 m236\text{ m}^2. And shapes with the same area can have different perimeters.

Misconception

"An angle gets bigger when its arms are drawn longer." An angle measures turn. Longer arms reach further, but the turn between them is the same.

Misconception

"Bigger triangles have bigger angle sums." Every triangle on a flat surface has angle sum 180∘180^\circ, whether it fits on a stamp or covers a football field.

Misconception

Writing the wrong units. Area is in square units (cm2\text{cm}^2, m2\text{m}^2), volume in cubic units (cm3\text{cm}^3), and perimeter in plain units of length (cm, m).

ViewpointsH

Other ways of seeing

Geometry— When angles add up to more than 180°

The 180∘180^\circ rule is a fact about flat surfaces. On a globe, draw a triangle from the North Pole down to the equator, a quarter of the way round the equator, and back up to the pole. All three angles are right angles: the sum is 270∘270^\circ! On a sphere, every triangle has an angle sum bigger than 180∘180^\circ, and the bigger the triangle, the bigger the sum. Geometers measure how curved a surface is by exactly this extra angle — see non-Euclidean geometry.

Analysis— The area of curved shapes

How can we find the area of a circle, when no square tiles fit it exactly? Cover it with smaller and smaller squares: the squares completely inside give an under-estimate, the squares touching it give an over-estimate, and as the squares shrink the two estimates squeeze together. Making this squeezing precise is part of what analysts do. Much later, measure theory asks which sets of points have an area at all — and finds, surprisingly, that if area must behave well even for infinitely many pieces, some very strange sets cannot be given any area.

Set-theoretic connectionH

Area, pieces and sets

When we split the L-shaped room into two strips, we used a rule about pieces: if a shape is made of two pieces that do not overlap (they may share an edge), its area is the area of one piece plus the area of the other. This is just like counting the members of two collections with nothing in common, from the lesson on sets. If the pieces do overlap, we must subtract the overlap once, just as ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = |A| + |B| - |A \cap B|.

History & global context

History and global context

  • In ancient Egypt, the Rhind Mathematical Papyrus (copied by the scribe Ahmes around 1550 BCE) contains problems about the areas of fields and the volumes of granaries. Measuring land mattered: the yearly Nile floods washed away field boundaries.
  • In China, the first chapter of The Nine Chapters on the Mathematical Art, compiled roughly two thousand years ago, is called Rectangular Fields and teaches how to find the areas of fields of many shapes.
  • In India, the Śulba-sūtras (written between about 800 and 200 BCE) give rules for building fire altars of exact shapes and areas, including how to make a square with the same area as a given rectangle.
  • Dividing a full turn into 360 degrees is usually traced back to astronomers in ancient Mesopotamia, who counted in sixties; Greek astronomers such as Hipparchus later used it, and it spread around the world.
  • Euclid's Elements (Alexandria, about 300 BCE), Book I, Proposition 32, proves that the angles of a triangle add up to two right angles, using a line parallel to one side — the same idea as our proof.
Further reading

For grown-ups: further reading

  • Paul Lockhart, Measurement (2012) — a joyful, thought-provoking book about measuring shapes, for teachers and curious adults.
  • Liping Ma, Knowing and Teaching Elementary Mathematics (1999) — chapter 4 discusses how teachers explore the relationship between perimeter and area.
  • Euclid, The Thirteen Books of the Elements, translated by Thomas L. Heath (1908) — Book I contains the angle sum of a triangle.