Algorithm
An algorithm is a finite sequence of mathematically rigorous instructions, used to solve a class of specific problems or to perform a computation. That definition sounds clinical, but it hides a strange lineage. The very word traces back to a single Persian scholar who wrote two books around 825 AD. His name, passed through Latin translators, became the label for an idea that now decides what videos you watch and what stocks get traded. How did a 9th-century method for arithmetic become the backbone of modern computing? And why are the newest machines starting to abandon the rigor that defined the concept in the first place? The answers run from a Sumerian clay tablet to a reinforcement learning system that rewrote a piece of standard software.
Muḥammad ibn Mūsā al-Khwārizmī wrote kitāb al-ḥisāb al-hindī, the "Book of Indian computation", around 825 AD. In the early 12th century, Latin translations of his work appeared, carrying the Hindu-Arabic numeral system into Europe. One such text, attributed to Adelard of Bath, was the Liber Algoritmi de numero Indorum. Its opening words were Dixit Algoritmi, meaning "Thus spoke Al-Khwarizmi". The word algorism entered English meaning the use of place-value notation in calculation. It appears in the Ancrene Wisse from around 1225. When Geoffrey Chaucer wrote The Canterbury Tales in the late 14th century, he described augrym stones, pebbles used for place-value sums. In the 15th century the Greek word arithmos, meaning "number", reshaped the Latin into algorithmus. By 1596, Thomas Hood used the form algorithm in English. The name had drifted far from the man, but his contribution went deeper than spelling, as the next chapter shows.
A Sumerian clay tablet found in Shuruppak near Baghdad, dated to around 2500 BC, describes the earliest known division algorithm. Step-by-step procedures for mathematical problems reach back into antiquity across many cultures. During the Hammurabi dynasty around 1800 BC, Babylonian clay tablets set down algorithms for computing formulas and even for predicting astronomical events. Egyptian arithmetic appears in the Rhind Mathematical Papyrus, dated to around 1550 BC. Hellenistic mathematics gave two famous examples. The Sieve of Eratosthenes was described in the Introduction to Arithmetic by Nicomachus. The Euclidean algorithm was first set out in Euclid's Elements, around 300 BC. Al-Khwārizmī, in the 9th century, did something different. In The Compendious Book on Calculation by Completion and Balancing, he moved past single numerical answers to general procedures for algebraic reduction and balancing. He turned mathematics into a mechanical process of well-defined rules. That same century, Al-Kindi wrote A Manuscript On Deciphering Cryptographic Messages, giving the first description of codebreaking by frequency analysis.
The verge escapement mechanism, producing the tick of mechanical clocks, was a key European invention of the Middle Ages. Accurate automatic machines led to mechanical automata in the 13th century, and eventually to the difference and analytical engines of Charles Babbage and Ada Lovelace in the mid-19th century. Lovelace designed the first algorithm intended for a computer, written for Babbage's analytical engine. That engine is described as the first real Turing-complete computer. Though the full second device was built only decades after her death, Lovelace has been called "history's first programmer". The Jacquard loom, a precursor to punch cards, fed into this lineage alongside telephone switching machines. Ticker tape arrived around the 1870s, punch cards around 1890, and the teleprinter around 1910 with its Baudot code on tape. Telephone-switching networks of electromechanical relays were invented in 1835. These led George Stibitz, in 1937, to build an experimental digital adder. Working at Bell Laboratories, he had found mechanical calculators with gears "burdensome", and tinkered with a better design at home.
In 1928, the modern concept of the algorithm began to take formal shape through attempts to solve David Hilbert's Entscheidungsproblem, the decision problem. Researchers tried to define what "effective calculability" or an "effective method" actually meant. The Gödel-Herbrand-Kleene recursive functions arrived across 1930-1934 and 1935. Alonzo Church introduced his lambda calculus in 1936. Emil Post published his Formulation 1 the same year. Alan Turing described his Turing machines across 1936-37 and 1939. These competing frameworks converged on a shared notion of mechanical computation. A Turing machine program can be expressed in several ways: as a sequence of machine tables, as flowcharts, or as rudimentary machine code called "sets of quadruples". Such descriptions sit at three accepted levels. A high-level description ignores how the machine is built. An implementation description explains how the head moves and stores data. A formal description gives the exact state table and list of transitions.
Knowing the time, storage, or other cost an algorithm needs is often vital. An algorithm that sums a list of n numbers need only remember two values: the running total and its current position in the list. A binary search outperforms a sequential search when looking up entries in sorted lists. The analysis and study of algorithms forms a discipline of computer science, often pursued abstractly without reference to any specific programming language. Pseudocode suits this work because it is simple and general. Yet most algorithms run on real hardware, and their efficiency gets tested with real code. Empirical testing can uncover unexpected interactions that affect performance, and benchmarks can compare an algorithm before and after optimization. Such tests cannot fully replace formal analysis and are difficult to run fairly. The stakes can be large. A recent innovation in the FFT algorithms used for image processing can cut processing time by up to 1,000 times for medical imaging. The best case of an algorithm is the input that demands the least time and resources; the worst case demands the most.
Brute force solves a problem by systematically trying every possible option until the optimal one is found, an approach used to crack passwords or find a shortest path. Divide-and-conquer instead reduces a problem to smaller copies of itself until each is easy, as merge sorting does by splitting and remerging a list. A simpler variant, prune and search, solves only one smaller instance with no merge step; binary search is an example. Recursion invokes itself until a termination condition is met, and the Tower of Hanoi is the classic puzzle solved this way. Every recursive version has an equivalent iterative one, and the reverse holds too. Algorithms also split by hardware. Serial algorithms run one instruction at a time, while parallel algorithms use multiple processors and distributed algorithms span machines on a network. Some problems, called inherently serial, have no parallel version. For optimization, the simplex algorithm tackles linear programming, and dynamic programming caches overlapping subproblems, as the Floyd-Warshall algorithm does for shortest paths. Greedy algorithms such as Kruskal and Prim build minimal spanning trees.
In 2023, Google DeepMind introduced AlphaDev, a reinforcement learning system based on AlphaZero. Reported in a paper in Nature, AlphaDev discovered small sorting algorithms that beat previously known human benchmarks. Those routines were integrated into the LLVM standard C++ sorting library. For decades, the assumed direction of progress ran the other way. Symbolic integration illustrates the old path. In 1961, James Slagle's program SAINT used heuristics to solve 52 of 54 freshman calculus exercises from an MIT textbook, roughly 96 percent. In 1967, Larry Moses's SIN refined those heuristics to 100 percent success, though it stayed heuristic. Then in 1969, Robert Risch introduced the Risch Algorithm with formal guarantees. The traditional trajectory ran from heuristics toward a definitive, guaranteed algorithm. The rise of transformer-based AI has inverted that sequence, with classical algorithms now giving way to heuristics again. In 2025, DeepMind introduced AlphaEvolve, an evolutionary coding agent powered by large language models. It proposes code changes, tests them with automated evaluators, and improves promising candidates over many iterations.
Up Next
Common questions
What is an algorithm in mathematics and computer science?
An algorithm is a finite sequence of mathematically rigorous instructions, typically used to solve a class of specific problems or to perform a computation. As an effective method, it can be expressed in a finite amount of space and time within a well-defined formal language. A program is an algorithm only if it eventually stops.
Where does the word algorithm come from?
The word algorithm comes from the Latinized name of the Persian scholar Muḥammad ibn Mūsā al-Khwārizmī, who wrote around 825 AD. Latin translations such as the Liber Algoritmi de numero Indorum opened with Dixit Algoritmi, meaning "Thus spoke Al-Khwarizmi". Influenced by the Greek word arithmos, the form algorithm was used in English by Thomas Hood in 1596.
What is the earliest known algorithm?
The earliest known algorithm is a division procedure described on a Sumerian clay tablet found in Shuruppak near Baghdad, dated to around 2500 BC. Step-by-step mathematical procedures also appear in Babylonian, Egyptian, Indian, Greek, Chinese, and Arabic mathematics.
Who wrote the first algorithm intended for a computer?
Ada Lovelace designed the first algorithm intended for a computer, written for Charles Babbage's analytical engine. Although the full second device was built only decades after her death, Lovelace has been called "history's first programmer".
How are algorithms classified by design paradigm?
Algorithms are classified by design paradigms including brute-force search, divide-and-conquer, search and enumeration, randomized algorithms, and reduction of complexity. For optimization problems they also fall into linear programming, dynamic programming, the greedy method, and heuristic methods.
How has AI been used to discover new algorithms?
In 2023, Google DeepMind introduced AlphaDev, a reinforcement learning system based on AlphaZero that discovered improved sorting and hashing algorithms later integrated into the LLVM standard C++ sorting library. In 2025, DeepMind introduced AlphaEvolve, an evolutionary coding agent powered by large language models that proposes, tests, and refines algorithms over multiple iterations.
All sources
34 references cited across the entry
- 3The Miller's TaleGeoffrey Chaucer
- 4BookA Glossary of Tudor and Stuart Words: Especially from the DramatistsWalter William Skeat — Clarendon Press — 1914
- 5BookInternational Handbook of Research in History, Philosophy and Science TeachingJudith V. Grabiner — Springer — December 2013
- 7BookThe Death Algorithm and Other Digital DilemmasRoberto Simanowski — MIT Press — 2018
- 8BookThe MIT Encyclopedia of the Cognitive SciencesEric Dietrich — MIT Press — 1999
- 9BookA History of Algorithms: From the Pebble to the MicrochipJean-Luc Chabert — Springer Science & Business Media — 2012
- 10BookContributions to the History of Indian MathematicsM. S. Sriram — Springer — 2005
- 12JournalMathematics of the Yoruba People and of Their Neighbors in Southern NigeriaClaudia Zaslavsky — 1970
- 13BookThe History of Mathematics: A Brief CourseRoger L. Cooke — John Wiley & Sons — 2005
- 14BookA History of Algorithms1999
- 15BookA Brief History of Cryptology and Cryptographic AlgorithmsJohn F. Dooley — Springer Science & Business Media — 2013
- 16JournalAncient Babylonian AlgorithmsDonald E. Knuth — 1972
- 17BookEpisodes from the Early History of AstronomyAsger Aaboe — Springer — 2001
- 18EratosthenesCourtney Ast — Wichita State University: Department of Mathematics and Statistics
- 19BookSelected Papers on Computer ScienceDonald E. Knuth — CSLI Publications — 1996
- 20JournalThe (black) art of run-time evaluation: Are we comparing algorithms or implementations?Hans-Peter Kriegel et al. — 2016
- 21Better Math Makes Faster Data NetworksGillian Conahan — discovermagazine.com — January 2013
- 23Best CaseNational Institute of Standards and Technology (NIST)
- 24worst caseNational Institute of Standards and Technology (NIST)
- 25BookAlgorithm Design: Foundations, Analysis, and Internet ExamplesMichael T. Goodrich et al. — John Wiley & Sons, Inc. — 2002
- 27NewsThe Experts: Does the Patent System Encourage Innovation?2013-05-16
- 28BookKnapsack Problems Hans Kellerer SpringerHans Kellerer et al. — Springer — 2004
- 29BookAlgorithm Design: Foundations, Analysis, and Internet ExamplesMichael T. Goodrich et al. — John Wiley & Sons — 2001
- 30JournalA Random Polynomial-time Algorithm for Approximating the Volume of Convex BodiesMartin Dyer et al. — January 1991
- 31AlphaDev discovers faster sorting algorithmsJune 7, 2023
- 32JournalFaster sorting algorithms discovered using deep reinforcement learningDaniel J. Mankowitz et al. — June 2023
- 34AlphaEvolve: A coding agent for scientific and algorithmic discoveryAlexander Novikov et al. — 2025