Medieval Arabic manuscript painting by Yahya ibn Mahmud al-Wasiti, 1237, of seven bearded scholars in turbans and robes debating beneath shelves of stacked books in a Baghdad library

Al-Khwarizmi and the House of Wisdom: The Man Who Gave Us the Algorithm

Baghdad, somewhere around the year 820. The city is barely sixty years old and already the biggest thing on earth west of China. Inside the circular walls of the Round City, the caliph’s palace sits at the exact center like a stone in a ring. Outside them, the Tigris is crowded with grain barges, a whole street sells nothing but books, and a mill on the riverbank turns rags into paper, the cheap new material that makes a book something a scholar can actually own.

Into this city comes a man from the far edge of the empire, from Khwarazm, an oasis country on the Silk Road near the Aral Sea. We do not know his face or his birthday. We know his name, Muhammad ibn Musa al-Khwarizmi, “the man from Khwarazm,” and we know what he did with the caliph’s money: he wrote a short book, with no symbols in it at all, that gave the world the word “algebra.” A Latin spelling of his own name would later give us “algorithm.” Not bad for an outsider.

100% Free · Free on YouTube: 45-minute film, 30-episode vertical series, 60-second trailer

This article is the companion piece to Al-Khwarizmi: Father of Algebra & the Algorithm, our AI-animated docudrama that follows the man from Khwarazm into the House of Wisdom and his ideas into every phone on earth. The full film is free on YouTube. Watch the Full Film Free →

A City Built in a Circle

The caliph al-Mansur founded Baghdad in 762 and drew it as a circle, with four gates facing the four corners of his empire. By the 790s the city had its paper mill, and by the 820s it had something rarer: a ruler who paid for ideas. Al-Ma’mun, who had won the throne in a civil war against his own brother, spent like a tech billionaire on Greek manuscripts, astronomers, and translators who could turn Euclid, Ptolemy and Aristotle into Arabic.

Jim Al-Khalili, the physicist whose book The House of Wisdom is the friendliest guide to this world, calls what happened next a scientific revolution centuries before Europe had one. Historians still argue over how grand the House of Wisdom was as an institution, but the translation movement it stood for was real and enormous, and that is the point. Our docudrama Al-Khwarizmi: Father of Algebra & the Algorithm calls ninth-century Baghdad “the Silicon Valley of its time”: a boomtown where the smartest people alive competed for a patron with bottomless pockets.

That is where our film opens, and if you want to see this city breathe before you read on, the full 45-minute cinematic edition is free right here.

AI-animated aerial view of ninth-century Baghdad at dawn, with domes, a fortified gate and market awnings, from our docudrama Al-Khwarizmi
Baghdad in the 820s, as we imagined it for Al-Khwarizmi: Father of Algebra & the Algorithm. Still from the docudrama. History Adventures, LLC.

The Outsider from the Silk Road

Khwarazm was a long way from anywhere, a green pocket on the Amu Darya where caravans from China, India and Persia swapped goods and, with them, ways of counting. Al-Khwarizmi was probably born there around 780 and died around 850. Almost everything else is guesswork, except the one fact that matters: the tenth-century Baghdad bookseller Ibn al-Nadim, who catalogued every author he could find, places him at al-Ma’mun’s court, working among the caliph’s books.

And what books. On one shelf sat Euclid’s Elements, freshly translated, with its airtight geometric proofs. On another sat the Sindhind, an Indian astronomy text brought to Baghdad a generation earlier, carrying Brahmagupta’s nine digits and a small round sign for nothing: zero. Greek rigor and Indian arithmetic had never been in the same room before. Al-Khwarizmi read both, and the fusion is his real claim to greatness.

Robed scholars reading manuscripts in a sunlit hall of bookshelves, an AI-animated vision of Baghdad's House of Wisdom from our docudrama
The House of Wisdom as our film pictures it: shafts of light, shelves of manuscripts, scholars arguing over texts. Still from Al-Khwarizmi: Father of Algebra & the Algorithm. History Adventures, LLC.

We built our docudrama around that moment of arrival: a young outsider walking into a high-stakes world of rival scholars, patrons and caliphs, with 55 years of his life to play out. The look, which our filmmakers call “Poetic Noir Realism,” is all candlelight and shadow, ink and gold, because that is what a life spent over manuscripts looked like. And there is a twist we could not resist: we told the story of the man who made generative AI possible using generative AI. We call it the recursive idea. The historians Jörg Matthias Determann and Anto Mohsin appear on camera to keep us honest.

Al-Khwarizmi, grey-bearded in an embroidered blue robe, reads an open manuscript beside a turbaned colleague in our AI-animated docudrama
Al-Khwarizmi with his manuscript, rendered in the “Poetic Noir Realism” style of our docudrama. Still from Al-Khwarizmi: Father of Algebra & the Algorithm. History Adventures, LLC.

Put yourself in his sandals. You have the caliph’s backing and the best library on earth. You could write a dense treatise to impress the court’s other scholars, or you could write a short, plain handbook for clerks dividing inheritances, merchants settling accounts and surveyors digging canals. What would you do? Al-Khwarizmi chose the clerks, and then proved every rule with Euclid’s geometry anyway. That double move, practical and rigorous at once, is why his book outlived everyone else’s.

A Square and Ten Roots Equal Thirty-Nine

The book is the Kitab al-Jabr wa-l-Muqabala, “the book of restoring and balancing,” and it contains not one x, not one equals sign, not even a numeral. Every number is spelled out in words. Here is its most famous problem: a square and ten of its roots together equal thirty-nine dirhems. In modern dress that is x² + 10x = 39. Al-Khwarizmi did not have the dress, so he told you a recipe instead.

Halve the number of roots: five. Multiply it by itself: twenty-five. Add that to thirty-nine: sixty-four. Take the square root: eight. Subtract the five you started with: three. The root is three, and the square is nine. The recipe works for any problem of this shape, which is the whole secret. Change the numbers and the steps stay the same.

Then he shows you why, with a picture. Draw a square whose side is the unknown root. Glue a strip two and a half units wide onto each of its four sides; together those strips are the “ten roots.” The shape now has four empty corners, each a little square of six and a quarter, twenty-five in all. Fill them in and you have one big square of area sixty-four, so its side is eight, and the original root is eight minus five. You have just “completed the square,” and you have watched algebra and geometry shake hands.

Two pages of a fourteenth-century Arabic manuscript of al-Khwarizmi's Algebra with red-ink square diagrams showing geometric solutions of quadratic equations
The completing-the-square diagrams in a medieval copy of al-Khwarizmi’s Algebra, Bodleian Libraries, Oxford, MS. Huntington 214. Public domain, via Wikimedia Commons.

The two words in the title are the two moves he allowed himself. Al-jabr, restoring, means moving a subtracted quantity across to the other side so that nothing is missing. Al-muqabala, balancing, means cancelling the same quantity from both sides. With those two moves he sorted every quadratic into six standard types and gave each one a recipe and a proof. Al-jabr became “algebra” in Latin, and the word kept its old meaning of mending too: in medieval Spain an algebrista was a bone-setter.

Why the Method Beat the Geniuses

He was not the first person to solve such a problem. Babylonian scribes were working out quadratics on clay tablets more than two thousand years before him. Diophantus of Alexandria filled his Arithmetica with ingenious solutions in the third century. Brahmagupta in India gave a general rule for quadratics in 628 and happily computed with zero and negative numbers, which al-Khwarizmi never did.

So give the others their due, and then give al-Khwarizmi his. The Babylonians left worked examples. Diophantus left brilliant tricks that only a Diophantus could repeat. Al-Khwarizmi left a system: a classification, a procedure for each case, a proof that it works, and language plain enough for a tax clerk. That is the difference between solving a problem and creating a subject. Methods travel. Tricks stay home.

He was not done. He compiled astronomical tables, wrote on the astrolabe, and produced a world geography that shrank Ptolemy’s overstretched Mediterranean closer to its true length. And he wrote a second short book, on calculating with the nine Indian digits and zero. The Arabic original is lost. Its afterlife is the strangest part of the story.

Brass planispheric astrolabe engraved with Arabic inscriptions, made in Yemen in 1291, Metropolitan Museum of Art
A brass astrolabe made in Yemen in 1291 by ‘Umar ibn Yusuf al-Muzaffari. Al-Khwarizmi wrote on the instrument four centuries earlier. The Metropolitan Museum of Art, New York. Public domain.

How a Scribe’s Spelling Became the Algorithm

Three hundred years later the center of gravity had shifted west. In 1145, in Segovia, an Englishman named Robert of Chester translated the Algebra into Latin; Gerard of Cremona did it again in Toledo. Around the same time a Latin version of the lost arithmetic book began to circulate, opening with the words Dixit Algorizmi: “Thus spoke al-Khwarizmi.” The scribes could not pronounce his name, so they wrote what they heard.

Anyone who calculated with the new digits was soon an “algorist,” and the craft was “algorism.” Over the centuries the spelling drifted toward the Greek word for number, arithmos, and came out the other end as “algorithm.” Fibonacci carried the digits into the counting houses of Italy in 1202. A man’s name had become a noun.

Today an algorithm means any finite list of exact steps that turns a question into an answer, and al-Khwarizmi’s recipe is a perfect specimen: halve, square, add, take the root, subtract. Scale that idea up by a few billion and you have the thing that routes your map and writes the next word out of an AI model. Our film ends in that present, because the thread is unbroken. A clerk’s handbook from a round city on the Tigris is still running, every second, inside the phone in your pocket.

100% FREE • GRANT-FUNDED • AWARD-WINNING DIGITAL LEARNING

Al-Khwarizmi: Father of Algebra & the Algorithm

An original AI-animated docudrama in the tradition of Rise of Empires: Ottoman. Follow a young outsider from Central Asia to the House of Wisdom in ninth-century Baghdad, where he fused Greek geometry and Indian arithmetic into algebra and gave the world the algorithm, told with the very technology his ideas made possible. Funded by a Doha Film Institute Web Series Grant and selected for the Qumra 2026 Series Lab, featuring historians Jörg Matthias Determann, PhD, and Anto Mohsin, PhD. Co-directed by Maha Al-Naemi. Created by Spencer Striker, PhD.

Educator tip: Watch the 45-minute film as a class, then hand students the recipe for “a square and ten roots equal thirty-nine” from this article and have them solve a new equation of the same shape (for example a square and six roots equal sixteen) in words only, no symbols, before drawing the completed square to prove it. Finish with a two-minute debate: was al-Khwarizmi an inventor or a great teacher?

Watch the Full Film Free Watch the 30-Episode Series About the Series

Sources and further reading

  • Watch: Medieval Baghdad: Rise and Fall of the City of Peace – DOCUMENTARY, Kings and Generals (YouTube). The Round City from its founding to the Mongol sack, in nineteen minutes.
  • Watch: The Dark Ages…How Dark Were They, Really?: Crash Course World History #14, CrashCourse (YouTube). John Green on why Europe’s “dark” centuries were Baghdad’s bright ones.
  • Play: Assassin’s Creed Mirage (Ubisoft, 2023; PlayStation, Xbox, PC). Ninth-century Baghdad rebuilt street by street, with the House of Wisdom as one of its landmarks. The plot is fiction; the city is a labor of love.
  • Listen: Maths in the Early Islamic World, BBC Radio 4, In Our Time (2017). Melvyn Bragg with Jim Al-Khalili, Colva Roney-Dougal and Peter Pormann on al-Khwarizmi and his successors.
  • Read: Jim Al-Khalili, The House of Wisdom: How Arabic Science Saved Ancient Knowledge and Gave Us the Renaissance (Penguin Press, 2011). The best popular history of Baghdad’s golden age, by a physicist who grew up in Iraq.
  • Read: The Algebra of Mohammed ben Musa, edited and translated by Frederic Rosen (London, 1831), free at the Internet Archive. Read “a square and ten roots” in al-Khwarizmi’s own words.

Featured image: Yahya ibn Mahmud al-Wasiti, Scholars in a Library, an illustration to the Maqamat of al-Hariri painted in Baghdad in 1237, now in the Bibliothèque nationale de France, Paris (MS Arabe 5847, fol. 5v). Public domain, via Wikimedia Commons.

By Spencer Striker, PhD, Professor of Digital Media Design at Northwestern University in Qatar, founding member of NU-Q’s Artificial Intelligence and Media Lab (AIM-LAB), and creator of History Adventures and Al-Khwarizmi: Father of Algebra & the Algorithm.

American Revolution AP World History AUDubai Campus Big History Big History Education Botany Bay Character Design Cultural Heritage Digital Design Digital Learning Digital Learning Innovation Empires & Interconnections Engaging Educational Games Engaging History Content Historical Exploration Games Historical Fiction Historical Narratives Historical Simulation Games History Apps History Books Interactive History Experiences Interactive Learning Mobile Learning Narrative Design Rebellion republic of pirates Revolution slavery US History World History Exam