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
Updated
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
93 references cited across the entry
- 1"A procedure which has all the characteristics of an algorithm except that it possibly lacks finiteness may be called a 'computational method (Knuth 1971:5).
- 2David A. Grossman, Ophir Frieder, Information Retrieval: Algorithms and Heuristics, 2nd edition, 2004,
- 3"Any classical mathematical algorithm, for example, can be described in a finite number of English words" (Rogers 1987:2).
- 4Well defined concerning the agent that executes the algorithm: "There is a computing agent, usually human, which can react to the instructions and carry out the computations" (Rogers 1987:2).
- 5"an algorithm is a procedure for computing a function (concerning some chosen notation for integers) ... this limitation (to numerical functions) results in no loss of generality", (Rogers 1977:1).
- 6"An algorithm has one or more outputs, i.e., quantities which have a specified relation to the inputs" (Knuth 1973:5).
- 7Whether or not a process with random interior processes (not including the input) is an algorithm is debatable. Rogers opines that: "a computation is carried out in a discrete stepwise fashion, withou
- 8Blair, Ann, Duguid, Paul, Goeing, Anja-Silvia and Grafton, Anthony. Information: A Historical Companion, Princeton: Princeton University Press, 2021. p. 247
- 10algorism
- 11The Miller's TaleGeoffrey Chaucer
- 12BookA Glossary of Tudor and Stuart Words: Especially from the DramatistsWalter William Skeat — Clarendon Press — 1914
- 13BookInternational Handbook of Research in History, Philosophy and Science TeachingJudith V. Grabiner — Springer — December 2013
- 15BookThe Death Algorithm and Other Digital DilemmasRoberto Simanowski — MIT Press — 2018
- 16BookThe MIT Encyclopedia of the Cognitive SciencesEric Dietrich — MIT Press — 1999
- 17Stone requires that "it must terminate in a finite number of steps" (Stone 1973:7–8).
- 18Boolos and Jeffrey 1974, 1999:19
- 19BookA History of Algorithms: From the Pebble to the MicrochipJean-Luc Chabert — Springer Science & Business Media — 2012
- 20BookContributions to the History of Indian MathematicsM. S. Sriram — Springer — 2005
- 22JournalMathematics of the Yoruba People and of Their Neighbors in Southern NigeriaClaudia Zaslavsky — 1970
- 23BookThe History of Mathematics: A Brief CourseRoger L. Cooke — John Wiley & Sons — 2005
- 24BookA History of Algorithms1999
- 25BookA Brief History of Cryptology and Cryptographic AlgorithmsJohn F. Dooley — Springer Science & Business Media — 2013
- 26JournalAncient Babylonian AlgorithmsDonald E. Knuth — 1972
- 27BookEpisodes from the Early History of AstronomyAsger Aaboe — Springer — 2001
- 28EratosthenesCourtney Ast — Wichita State University: Department of Mathematics and Statistics
- 29BookSelected Papers on Computer ScienceDonald E. Knuth — CSLI Publications — 1996
- 30Bolter 1984:24
- 31Bolter 1984:26
- 32Bolter 1984:33–34, 204–206.
- 33Bell and Newell diagram 1971:39, cf. Davis 2000
- 34Melina Hill, Valley News Correspondent, A Tinkerer Gets a Place in History, Valley News West Lebanon NH, Thursday, March 31, 1983, p. 13.
- 35Davis 2000:14
- 36Kleene 1943 in Davis 1965:274
- 37Rosser 1939 in Davis 1965:225
- 38JournalSequential abstract-state machines capture sequential algorithmsYuri Gurevich — 2000
- 39BookNew Computational ParadigmsYiannis N. Moschovakis et al. — Springer — 2008
- 40Sipser 2006:157
- 41JournalThe (black) art of run-time evaluation: Are we comparing algorithms or implementations?Hans-Peter Kriegel et al. — 2016
- 42Better Math Makes Faster Data NetworksGillian Conahan — discovermagazine.com — January 2013
- 44Best CaseNational Institute of Standards and Technology (NIST)
- 45worst caseNational Institute of Standards and Technology (NIST)
- 46BookAlgorithm Design: Foundations, Analysis, and Internet ExamplesMichael T. Goodrich et al. — John Wiley & Sons, Inc. — 2002
- 48Tausworthe 1977:101
- 49Tausworthe 1977:142
- 50Knuth 1973 section 1.2.1, expanded by Tausworthe 1977 at pages 100ff and Chapter 9.1
- 51NewsThe Experts: Does the Patent System Encourage Innovation?2013-05-16
- 52BookKnapsack Problems Hans Kellerer SpringerHans Kellerer et al. — Springer — 2004
- 53BookAlgorithm Design: Foundations, Analysis, and Internet ExamplesMichael T. Goodrich et al. — John Wiley & Sons — 2001
- 54JournalA Random Polynomial-time Algorithm for Approximating the Volume of Convex BodiesMartin Dyer et al. — January 1991
- 55George B. Dantzig and Mukund N. Thapa. 2003. Linear Programming 2: Theory and Extensions. Springer-Verlag.
- 56AlphaDev discovers faster sorting algorithmsJune 7, 2023
- 57JournalFaster sorting algorithms discovered using deep reinforcement learningDaniel J. Mankowitz et al. — June 2023
- 59AlphaEvolve: A coding agent for scientific and algorithmic discoveryAlexander Novikov et al. — 2025
- 60JournalOn a Subrecursive Hierarchy and Primitive Recursive DegreesP Axt — 1959
- 61JournalAlgorithms: A Quest for Absolute DefinitionsAndreas Blass et al. — 2003
- 62BookTuring's Man: Western Culture in the Computer AgeDavid J. Bolter — The University of North Carolina Press — 1984
- 63BookComputability and LogicGeorge Boolos et al. — Cambridge University Press, London — 1999
- 64BookSuper-Recursive AlgorithmsMark Burgin — Springer — 2004
- 65JournalAn Unsolvable Problem of Elementary Number TheoryAlonzo Church — 1936
- 66JournalA Note on the EntscheidungsproblemAlonzo Church — 1936
- 67JournalCorrection to a Note on the EntscheidungsproblemAlonzo Church — 1936
- 68BookThe Muslim contribution to mathematicsAli Abdullah al- Daffa' — Croom Helm — 1977
- 69BookThe Undecidable: Basic Papers On Undecidable Propositions, Unsolvable Problems and Computable FunctionsMartin Davis — Raven Press — 1965
- 70BookEngines of Logic: Mathematicians and the Origin of the ComputerMartin Davis — W.W. Nortion — 2000
- 71JournalEvolution and moral diversityDean, Tim — 2012
- 72BookDarwin's Dangerous IdeaDaniel Dennett — Touchstone/Simon & Schuster — 1995
- 73BookThe AbacusJesse Dilson — St. Martin's Press, NY — 2007
- 74BookFrom Frege to Gödel, A Source Book in Mathematical Logic, 1879–1931Jean van Heijenoort — Harvard University Press, Cambridge — 2001
- 75BookAlan Turing: The EnigmaAndrew Hodges — Simon and Schuster — 1983
- 76JournalGeneral Recursive Functions of Natural NumbersStephen C. Kleene — 1936
- 77JournalRecursive Predicates and QuantifiersStephen C. Kleene — 1943
- 78BookIntroduction to MetamathematicsStephen C. Kleene — North-Holland Publishing Company — 1991
- 79BookFundamental Algorithms, Third EditionDonald Knuth — Addison–Wesley — 1997
- 80BookVolume 2/Seminumerical Algorithms, The Art of Computer Programming First EditionDonald Knuth — Addison–Wesley — 1969
- 81JournalAlgorithm=Logic+ControlRobert Kowalski — 1979
- 82BookComputation: Finite and Infinite MachinesMarvin Minsky — Prentice-Hall, Englewood Cliffs, NJ — 1967
- 83JournalFinite Combinatory Processes, Formulation IEmil Post — 1936
- 84BookTheory of Recursive Functions and Effective ComputabilityHartley Jr. Rogers — The MIT Press — 1987
- 85JournalAn Informal Exposition of Proofs of Godel's Theorem and Church's TheoremJ.B. Rosser — 1939
- 86BookMachine Medical EthicsChristopher Santos-Lang — Springer — 2015
- 87BookProgramming Language PragmaticsMichael L. Scott — Morgan Kaufmann Publishers/Elsevier — 2009
- 88BookIntroduction to the Theory of ComputationMichael Sipser — PWS Publishing Company — 2006
- 89BookUnto Others: The Evolution and Psychology of Unselfish BehaviorElliott Sober et al. — Harvard University Press — 1998
- 90BookIntroduction to Computer Organization and Data StructuresHarold S. Stone — McGraw-Hill, New York — 1971
- 91BookStandardized Development of Computer Software Part 1 MethodsRobert C Tausworthe — Prentice–Hall, Inc. — 1977
- 92JournalOn Computable Numbers, With An Application to the EntscheidungsproblemAlan M. Turing — 1936–37
- 93JournalSystems of Logic Based on OrdinalsAlan M. Turing — 1939