In mathematics and computer science, an algorithm (i// AL-gə-ri-dhəm) is a self-contained step-by-step set of operations to be performed. Algorithms perform calculation, data processing, and/or automated reasoning tasks.
The English word 'algorithm' comes from Medieval Latin word algorism and the Greek word "arithmos" (ἀριθμός). The word 'algorism' (and therefore, the derived word 'algorithm') comes from Al-Khwārizmī (Persian: خوارزمی, c. 780–850), a Persian mathematician, astronomer, geographer, and scholar. English adopted the French term, but it wasn't until the late 19th century that "algorithm" took on the meaning that it has in modern English.
In English, it was first used about 1230 and then by Chaucer in 1391. Another early use of the word is from 1240, in a manual titled Carmen de Algorismo composed by Alexandre de Villedieu.
It begins thus:
Haec algorismus ars praesens dicitur, in qua / Talibus Indorum fruimur bis quinque figuris.
which translates as:
Algorism is the art by which at present we use those Indian figures, which number two times five.
The poem is not very long, only a few hundred lines, and summarizes the art of calculating with the new style of Indian dice, or Talibus Indorum, or Hindu numerals or al-adad al-Hindi
An algorithm is an effective method that can be expressed within a finite amount of space and time and in a well-defined formal language for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input.
The concept of algorithm has existed for centuries; however, a partial formalization of what would become the modern algorithm began with attempts to solve the Entscheidungsproblem (the "decision problem") posed by David Hilbert in 1928. Subsequent formalizations were framed as attempts to define "effective calculability" or "effective method"; those formalizations included the Gödel–Herbrand–Kleene recursive functions of 1930, 1934 and 1935, Alonzo Church's lambda calculus of 1936, Emil Post's "Formulation 1" of 1936, and Alan Turing's Turing machines of 1936–7 and 1939. Giving a formal definition of algorithms, corresponding to the intuitive notion, remains a challenging problem.