Completing the square · al-Khwarizmi, c. 820

An unfinished square, and the birthplace of the algorithm

About twelve hundred years ago in Baghdad, Muhammad ibn Musa al-Khwarizmi solved a problem by drawing a figure with one piece missing. He built the missing piece, completed the square and read off the answer, with no guessing. The PARAN mark is that figure.

c. 820 CE
The Compendious Book on Calculation by Completion and Balancing, House of Wisdom, Baghdad
al-jabr
“restoration, completion”: the root of the word algebra
Algoritmi
al-Khwarizmi's Latin name: the root of the word algorithm
+25
x² + 10x = 39Your organisation's processes and data
+ 25AI and data science

Completing the square · al-Khwarizmi, c. 820

A scholar’s desk by oil-lamp light: a manuscript with the completing-the-square figure, the same figure rising from the page as blue light
The story in four steps

A problem solved with a drawing

01

The problem

A square and ten times its side make 39. How long is the side? Today we write x² + 10x = 39.

02

The figure

He draws a square of side x, splits “ten x” into two rectangles of five, and attaches them to two sides. The result is an L-shaped figure of area 39.

03

The missing piece

One corner is empty: a 5 by 5 square, 25. He adds it, and the figure becomes a complete square of area 64.

04

The answer

The side of a 64 square is 8. Take away the 5 that was added and 3 remains. Solved by a clear procedure, not by guessing.

Build it yourself

Complete the square, step by step

Tap a step to build the figure. Change the numbers with the sliders: the same thousand-year-old recipe solves every equation of this family.

x²5x5x+25x5x + 5

x² + 10x = 39

The problem

A square of unknown side x and a strip of area 10x; together 39 units.

The same recipe, as an algorithm
# x² + 10x = 39h = 10 / 2   → 5s = h * h    → 25t = 39 + s   → 64r = √t       → 8x = r − h    → 3
  1. Halve the coefficient of x
  2. Square the result (multiply it by itself)
  3. Add it to the right-hand side
  4. Take the square root of the sum
  5. Subtract the result of step 1

al-Khwarizmi wrote this recipe in words, not symbols, but its steps are what a program runs today: an input, fixed steps, an output. That is why his name lives on in the word “algorithm”.

For the curious

From completing the square to machine learning

A simple geometric trick sits under a large part of today's computational mathematics.

The general formula

Any equation x² + bx = c is solved by the same figure: square half of b and add it to both sides.

x² + bx + (b/2)² = c + (b/2)²
(x + b/2)² = c + b²/4
x = √(c + b²/4) − b/2

The root geometry could not see

The equation also has the answer −13. A negative length cannot be drawn, so al-Khwarizmi set it aside. Modern algebra keeps both.

x + 5 = ±8
x = 3   or   x = −13

Two proofs, one idea

al-Khwarizmi drew two figures. In the first, “ten x” becomes four strips of 2.5 and four small corner squares complete it. In the second, the one in the PARAN mark, two strips of 5 and one square of 25.

4 × 2.5² = 25
5² = 25

The minimum of every parabola

Completing the square shows where any quadratic function reaches its minimum. That is the core of optimisation.

ax² + bx + c = a(x + b/2a)² + c − b²/4a
x* = −b / 2a

The same step, in many dimensions

With a vector of thousands of parameters instead of one number, completing the square takes matrix form. Least-squares regression, the Kalman filter and Gaussian distributions and processes in machine learning all rest on it.

xᵀAx − 2bᵀx
  = (x − A⁻¹b)ᵀ A (x − A⁻¹b) − bᵀA⁻¹b
x* = A⁻¹b

From al-jabr to data

al-Khwarizmi put the problem in a standard form, built the missing piece and read the answer without guessing. Data science and AI do the same three things with an organisation's data today.

standardise → complete → solve
The PARAN mark

Why this figure is our mark

L · 39

What your organisation has: processes, data and experience. Valuable, but incomplete.

Square · 25

The piece that completes it: data infrastructure, data science and AI.

64 = 8²

A more complete organisation: work that is recorded, analysed and turned into decisions.

One unit apart

The square sits one step out so the proof stays visible; we show every number and every result with its trail.

Source: Muhammad ibn Musa al-Khwarizmi, al-Kitab al-mukhtasar fi hisab al-jabr wa-l-muqabala, Baghdad, c. 820. The example x² + 10x = 39 and both proof figures come from this book.

Which piece is your organisation missing?

Tell us what is scattered, slow or uncertain today; we will complete the square together.