
A 9th-century scholar in Baghdad invented the methods behind every equation you solve and every algorithm your computer runs.
The House of Wisdom
In the year 820 CE, in the great city of Baghdad, there stood a place unlike any other on Earth. It was called Bayt al-Hikma — the House of Wisdom. It was not a palace, though caliphs funded it. It was not a mosque, though scholars prayed there. It was a library, a translation centre, a research institute, and a meeting ground for the finest minds in the world, all at once.
The Abbasid Caliph al-Ma’mun had commanded that the collected knowledge of every civilisation — Greek, Indian, Persian, Chinese — be translated into Arabic. Scrolls arrived from Constantinople, manuscripts from the libraries of India, astronomical tables from Persia. Scholars who spoke a dozen languages worked side by side, pouring the world’s learning into a single tongue.
Among them was a quiet, methodical man named Muhammad ibn Musa al-Khwarizmi. He was not the loudest voice in the House of Wisdom, nor the most flamboyant. But he would become the most influential.
The Problem of Inheritance
Al-Khwarizmi was asked to solve a practical problem. Under Islamic law, when a man died, his property had to be divided among his heirs according to precise rules: the wife receives one-eighth, each son receives twice what each daughter gets, debts must be paid first, and a charitable bequest must be honoured. The numbers were different for every family. Judges and lawyers needed a method that worked every time, not just for one particular case.
Al-Khwarizmi realised that the key was to give the unknown a name. He called it al-shay’ — the "thing." If the total estate was unknown, call it shay’. If each daughter’s share was unknown, call it shay’. Once the unknown had a name, the inheritance rules became equations, and equations could be solved.
He described two fundamental operations. The first was al-jabr — "restoration" — the act of moving a subtracted term from one side of an equation to the other, turning it positive. If you have x − 5 = 7, al-jabr restores the 5 by moving it: x = 7 + 5 = 12. The second was al-muqabala — "balancing" — simplifying by combining like terms on each side.
From the first operation, we get the word algebra. From his name, we get the word algorithm.
The Book
Al-Khwarizmi wrote it all down in a book whose title begins with the words Kitab al-Jabr wa al-Muqabala — "The Book of Restoration and Balancing." It was the first systematic treatment of algebra in history.
The book classified every equation into six types based on which terms appeared: things (what we call x), squares (x²), and numbers (constants). For each type, al-Khwarizmi gave a clear, step-by-step method to find the answer. Not a hint. Not a trick for one particular problem. A procedure that would work for any equation of that type, every time, for anyone who followed the steps.
For quadratic equations — those involving x² — he invented a technique so beautiful that mathematicians still teach it today. He called it "completing the square." Imagine you have a square garden of unknown size (x by x) and a rectangular strip added to one side. The total area is known. Al-Khwarizmi showed how to rearrange the pieces into a perfect, larger square, then simply measure its side. The unknown revealed itself through geometry.
He did not use symbols. He wrote everything in words: "Take the thing, multiply by itself, add ten of the thing, the result is thirty-nine." But the logic was flawless. And it was general — the same words, the same steps, worked for every problem of that form.
The Legacy
When Latin scholars translated his work three hundred years later, they could not pronounce his name. Muhammad ibn Musa al-Khwarizmi became Algoritmi in Latin. And when people referred to his step-by-step methods, they called them algorithms.
Today, every line of code on every computer runs an algorithm. Every search engine, every GPS route, every AI model, every encrypted message uses algorithmic thinking. And every time you solve an equation by moving terms from one side to the other, you are performing al-jabr — exactly as al-Khwarizmi described twelve hundred years ago.
He did not invent numbers. He did not discover geometry. What he did was something equally profound: he taught the world that problems can be solved by following precise, step-by-step procedures. Not by intuition. Not by trial and error. By method.
That idea changed everything.
The end.
Choose your level. Everyone starts with the story — the code gets deeper as you go.
Here is a taste of what Level 1 looks like for this lesson:
# Al-Khwarizmi's Balance Method
# Solve ax + b = c for any a, b, c
def solve_linear(a, b, c):
"""Al-Jabr: move b, then divide by a."""
print(f"Equation: {a}x + {b} = {c}")
print(f"Step 1 (al-Jabr): {a}x = {c} - {b} = {c - b}")
x = (c - b) / a
print(f"Step 2 (al-Muqabala): x = {c - b} / {a} = {x}")
return x
solve_linear(3, 7, 22)
# Output: x = 5
# Check: 3(5) + 7 = 22 ✓This is just the first of 6 coding exercises in Level 1. By Level 4, you will build: Build an Al-Khwarizmi Equation Solver.
By Level 4, enrolled students build: Build an Al-Khwarizmi Equation Solver
Free
Level 0: Listener
Stories, science concepts, diagrams, quizzes. No coding.
You are here
Level 0 is always free. Coding levels (1-4) are part of our 12-Month Curriculum.
The mathematics al-Khwarizmi invented — variables, equations, completing the square — and the algorithmic thinking that bears his name.
The big idea: "Al-Khwarizmi and the Language of Algebra" teaches us about Algebra & Algorithm Design — and you don't need to write a single line of code to understand it.
Imagine you have a bag of marbles. You do not know how many are inside. But someone tells you: "If you add 5 marbles to the bag, you will have 12." How many were in the bag? You can figure it out: 12 minus 5 equals 7. Simple. But al-Khwarizmi realised something profound: you can give the unknown a name. Call it x. Now the problem becomes an equation: x + 5 = 12.
An equation is a balance. Whatever is on the left side must equal the right side. Think of an old-fashioned scale with two pans. If both sides weigh the same, the scale is level. If you add a weight to one side, you must add the same weight to the other side to keep it balanced. This is the most important idea in algebra: whatever you do to one side, you must do to the other.
Al-Khwarizmi called this al-jabr — "restoration." If you have x − 3 = 7, you "restore" the 3 by adding it to both sides: x = 7 + 3 = 10. His other technique, al-muqabala ("balancing"), means combining like terms: if you have 3x + 2x = 25, you combine the x terms: 5x = 25, so x = 5.
Check yourself: If 4x + 6 = 22, what do you do first? What is x?
Key idea: An equation is a balance. A variable is a name for an unknown number. Al-Jabr (algebra) means keeping the balance by doing the same operation to both sides.
A linear equation with one variable, like 3x + 2 = 14, has exactly one answer (x = 4). But a linear equation with two variables, like y = 2x + 1, has infinitely many answers. When x = 0, y = 1. When x = 1, y = 3. When x = 2, y = 5. Each pair (x, y) is a point, and all these points form a straight line on a coordinate grid.
The equation y = mx + b is called the slope-intercept form. The letter m is the slope — how steep the line is. If m = 2, the line goes up 2 units for every 1 unit it moves to the right. The letter b is the y-intercept — where the line crosses the vertical axis.
Why does this matter? Because linear equations model real things. If a rickshaw driver charges 10 rupees to start plus 5 rupees per kilometre, the fare is y = 5x + 10. The slope (5) is the rate. The intercept (10) is the starting fee. Plotting this line shows you the fare for any distance at a glance.
Al-Khwarizmi used algebra to solve merchant problems exactly like this: "A trader buys goods at a fixed cost plus a per-unit rate." His equations were linear, and his solutions were the ancestors of every graph you have ever seen.
Check yourself: In y = 3x + 7, what is the slope and what is the y-intercept? If x = 10, what is y?
Key idea: A linear equation with two variables describes a straight line. The slope tells you the rate of change; the intercept tells you the starting value. Every line on every graph traces back to the algebra al-Khwarizmi formalised.
Access all 130+ lessons, quizzes, interactive tools, and offline activities
Some problems involve a variable **multiplied by itself**: x². These are **quadratic** equations, and they describe curves called **parabolas**. When ...
Al-Khwarizmi did something no mathematician before him had done: he wrote down **general procedures** that work for any equation of a given type. Not ...