← Construction algorithms

📖 Test and fix an algorithm

The rule

  • An algorithm is a list of steps, in the right order, that always works.
  • A step can hide a decision. “Open wider than half of AB” beats “open to 2 cm”.
  • Test an algorithm on new cases: a short line, a long line, a slanted line.
  • If it fails, find the step that broke. When the arcs miss, the width step is the culprit.
  • Fix one step, then run the whole list again on every test case.
  • Arcs from A and B cross twice only if the width is more than half of AB.
  • A missing or swapped step breaks a list too. The ruler step needs P and Q from earlier steps.
  • Using the whole of AB as the width is always more than half.

Examples

Pip opens to 2 cm. AB is 7 cm. Do the arcs cross? → No, the arcs miss

  1. Half of 7 cm is 3.5 cm
  2. Pip's width, 2 cm, is less than 3.5 cm
  3. So the arcs miss

A width less than half of AB cannot reach across.

ABW

Fix Pip's step so it works for every AB. → Open the compass to AB

  1. The arcs must cross, so the width must be more than half of AB
  2. The whole of AB is always more than half
  3. New step: open to AB

The whole of AB is always more than half of AB.

AB

Pip skips the step “mark P and Q”. What breaks? → The ruler has no points to join

  1. The ruler step joins P and Q
  2. Without the marks there are no points to tap
  3. So the ruler step cannot run

Each step needs what the steps before it made.

AB

Which test cases should you try on a new step list? → Short, long and slanted lines

  1. A short line may hide a width problem
  2. A long line shows if the width is too small
  3. A slanted line shows the steps do not depend on direction

Different cases catch different problems.

ABPQ

Watch out

  • “It worked once, so it always works.” No: test on new cases too.
  • “Change many steps at once.” No: fix one step, then test again, so you know what helped.
  • “Half of AB is wide enough.” No: exactly half only makes the arcs touch. Go wider.
Start the lesson ▶