Constructing a Perfect Square

Can you work out how to draw a perfect square with only a straight edge and compass. That is the sort of challenge the Ancient Greek Mathematician Euclid set himself. You need to devise an algorithm to do it – a sequence of steps that guarantee you end up with a square.

Try it before you read on. It is a fairly simple algorithm but one where, as we will see, decomposition can help – break it up into two simpler tasks and so algorithms.

Here for starters is my full algorithm for drawing a square. It does give you a square, but it is hard to follow and it was just as hard to work out. I kept getting confused with which circle was which, and being sure what we did really was what I intended…what a nightmare.

Square.jpg

  1. Draw a circle with radius AB centred on A, a point on a line to give a point B where line and circle cross.
  2. Draw a circle with radius AB centred on point B. This gives two points C and D where the circles cross.
  3. Draw a line through C and D. This is now at right angles to the original line. This gives a new point E where the two lines cross.
  4. Draw a circle with radius EC, centred on E. This gives a new point F where the circle crosses the original line in the circle.
  5. Draw a circle radius EF centred on F.
  6. Draw a circle radius EF centred on C, to make a new point G where this circle crosses the previous circle.
  7. Draw a line FG
  8. Draw a line GC
  9. You have a perfect square CEFG.

Phew! Hope I didn’t make a mistake.

Decomposition

Here is a much simpler version, that makes it clearer what is going on. It uses exactly the same steps ultimately.

  1. Draw a right-angled triangle
  2. Draw an identical right-angled triangle on the original’s longest side.

It works because a square is just two right angled triangles back to back. To solve the problem this way you have to just work out algorithms for those two simpler problems. If you rub out all the working lines and circles in between the steps then it will also be much easier to see what you are doing and that it is correct.

See if you can work out these two algorithms yourself. (Our versions are to coming soon)

Decomposing a complicated task in to clear, smaller tasks like this and then devising algorithms for them is the basis of how we now write complex software. It is a way of managing the complexity so that solving complex problems is no harder than solving the simpler problems.

More on Euclid and algorithms for creating perfect shapes


This work was supported by the Institute of Coding, which is supported by the Office for Students (OfS).

IoC logo on white