Mathematics is the study of quantity, structure, space, change, and related topics of pattern and form. Mathematicians seek out patterns whether found in numbers, space, natural science, computers, imaginary abstractions, or elsewhere.... and computer science
Computer science
Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems.... , is a method of defining functions
Function (mathematics)
The mathematical concept of a function expresses dependence between two quantities, one of which is known and the other which is produced. A function associates a single output to each input element drawn from a fixed Set , such as the real numbers , although different inputs may have the same output.... in which the function being defined is applied within its own definition. The term is also used more generally to describe a process of repeating objects in a self-similar way. For instance, when the surfaces of two mirrors are almost parallel with each other the nested images that occur are a form of infinite recursion
Recursion
Recursion, in mathematics and computer science, is a method of defining Function in which the function being defined is applied within its own definition.... .
The Fibonacci sequence is a classic example of recursion:
Although many mathematical functions can be expressed recursively, the overhead of actually applying the recursive definition may be prohibitive.
Mathematics is the study of quantity, structure, space, change, and related topics of pattern and form. Mathematicians seek out patterns whether found in numbers, space, natural science, computers, imaginary abstractions, or elsewhere.... and computer science
Computer science
Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems.... , is a method of defining functions
Function (mathematics)
The mathematical concept of a function expresses dependence between two quantities, one of which is known and the other which is produced. A function associates a single output to each input element drawn from a fixed Set , such as the real numbers , although different inputs may have the same output.... in which the function being defined is applied within its own definition. The term is also used more generally to describe a process of repeating objects in a self-similar way. For instance, when the surfaces of two mirrors are almost parallel with each other the nested images that occur are a form of infinite recursion
Recursion
Recursion, in mathematics and computer science, is a method of defining Function in which the function being defined is applied within its own definition.... .
Mathematics is the study of quantity, structure, space, change, and related topics of pattern and form. Mathematicians seek out patterns whether found in numbers, space, natural science, computers, imaginary abstractions, or elsewhere.... and computer science
Computer science
Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems.... , a class of objects or methods defined by a simple base case (or cases) and rules to reduce all other cases toward the base case.
For example, the following is a recursive definition of a person's ancestors:
A parent is a mother or father; one who sexual reproduction or gives birth to and/or nurtures and raises an offspring. The different roles of parents vary throughout the tree of life, and are especially complex in human culture.... s are one's ancestor
Ancestor
An ancestor is a parent or the parent of an ancestor .Two individuals have a genetics relationship if one is the ancestor of the other, or if they share a common ancestor.... s (base case).
The parents of one's ancestors are also one's ancestors (recursion step).
The Fibonacci sequence is a classic example of recursion:
Fib(0) is 1 [base case]
Fib(1) is 1 [base case]
For all integers n > 1: Fib(n) is (Fib(n-1) + Fib(n-2)) [recursive definition]
Although many mathematical functions can be expressed recursively, the overhead of actually applying the recursive definition may be prohibitive. For example:
Factorial(1) is 1 [base case]
For all integers n > 1: Factorial(n) is (n * Factorial(n-1)) [recursive definition]
A convenient mental model is that a recursive definition defines objects in terms of "previously defined" objects of the class to define. For example: How do you move a stack of 100 boxes? Answer: you move one box, remember where you put it, and then solve the smaller problem: how do you move a stack of 99 boxes? Eventually, you're left with the problem of how to move a single box, which you know how to do.
Definitions such as these are often found in mathematics. For example, the formal definition of natural number
Natural number
In mathematics, a natural number can mean either an element of the Set = *n = = ? = ? ... s in set theory is: 1 is a natural number, and each natural number has a successor, which is also a natural number.
Here is another, perhaps simpler way to understand recursive processes:
Are we done yet? If so, return the results. Without such a termination condition a recursion would go on forever.
If not, simplify the problem, solve the simpler problem(s), and assemble the results into a solution for the original problem. Then return that solution.
A more humorous illustration goes: "In order to understand recursion, one must first understand recursion." Or perhaps more accurate is the following, from Andrew Plotkin
Andrew Plotkin
Andrew Plotkin , also known as Zarf, is an award-winning interactive fiction author and an important figure in the modern interactive fiction community.... : "If you already know what recursion is, just remember the answer. Otherwise, find someone who is standing closer to Douglas Hofstadter
Douglas Hofstadter
Douglas Richard Hofstadter is an United States academic whose research focuses on consciousness, thinking and creativity. He is best known for G?del, Escher, Bach, first published in 1979, for which he was awarded the 1980 Pulitzer Prize for general non-fiction.... than you are; then ask him or her what recursion is."
Examples of mathematical objects often defined recursively are function
Function (mathematics)
The mathematical concept of a function expresses dependence between two quantities, one of which is known and the other which is produced. A function associates a single output to each input element drawn from a fixed Set , such as the real numbers , although different inputs may have the same output.... s, sets, and especially fractal
Fractal
A fractal is generally "a rough or fragmented Shape that can be split into parts, each of which is a reduced-size copy of the whole," a property called self-similarity.... s.
Linguistics is the science study of natural language. Linguistics encompasses a number of sub-fields. An important topical division is between the study of language structure and the study of Meaning .... , and the use of recursion in general, dates back to the ancient India
Indian subcontinent
The Indian subcontinent is a large section of the Asian continent consisting of the land lying substantially on the Indian Plate. The subcontinent includes parts of various countries in South Asia, including those on the continental crust , an Island#Continental islands country on the continental shelf , and an Island#Oceanic islands countr... n linguist in the 5th century BC, who made use of recursion in his grammar
Grammar
Grammar is the field of linguistics that covers the conventions governing the use of any given natural language. It includes morphology and syntax, often complemented by phonetics, phonology, semantics, and pragmatics.... rules of Sanskrit
Sanskrit
Sanskrit is a historical Indo-Aryan language, one of the liturgical languages of Hinduism and Buddhism, and one of the 22 official languages of India.... .
Avram Noam Chomsky is an United States linguistics, philosopher, cognitive science, political activist, author, and lecturer. He is an Institute Professor emeritus and professor emeritus of linguistics at the Massachusetts Institute of Technology.... theorizes that unlimited extension of a language such as English
English language
English is a West Germanic language that originated in Anglo-Saxon England and has lingua franca status in many parts of the world as a result of the military, economic, scientific, political and cultural influence of the British Empire in the 18th, 19th and early 20th centuries and that of the United States from the mid 20th century onwa... is possible only by the recursive device of embedding sentences in sentences. Thus, a chatty person may say, "Dorothy, who met the wicked Witch of the West in Munchkin Land where her wicked Witch sister was killed, liquidated her with a pail of water." Clearly, two simple sentences — "Dorothy met the Wicked Witch of the West in Munchkin Land" and "Her sister was killed in Munchkin Land" — can be embedded in a third sentence, "Dorothy liquidated her with a pail of water," to obtain a very verbose sentence.
However, if "Dorothy met the Wicked Witch" can be analyzed as a simple sentence, then the recursive sentence "She lived in the house Jack built" could be analyzed that way too, if "Jack built" is analyzed as an adjective, "Jack-built", that applies to the house in the same way "Wicked" applies to the Witch. "She lived in the Jack-built house" is unusual, perhaps poetic sounding, but it is not clearly wrong.
The idea that recursion is the essential property that enables language is challenged by linguist
Linguistics
Linguistics is the science study of natural language. Linguistics encompasses a number of sub-fields. An important topical division is between the study of language structure and the study of Meaning .... Daniel Everett
Daniel Everett
Daniel Leonard Everett is a linguistics professor best known for his study of the Amazon Basin's Pirah? people and Pirah? language.He currently serves as Chair of the Department of Languages, Literatures and Cultures at Illinois State University in Normal, Illinois.... in his work Cultural Constraints on Grammar and Cognition in Pirahã: Another Look at the Design Features of Human Language in which he hypothesizes that cultural factors made recursion unnecessary in the development of the Pirahã language
Pirahã language
Pirah? is a language spoken by the Pirah? people — an indigenous people of Amazonas , Brazil, who live along the Maici river, a tributary of the Amazon River.... . This concept challenges Chomsky's idea that recursion is the only trait which differentiates human and animal communication and is currently under intense debate.
Recursion in linguistics enables 'discrete infinity' by embedding phrases within phrases of the same type in a hierarchical structure. Without recursion, language does not have 'discrete infinity' and cannot embed sentences into infinity (with a 'Russian doll' effect). Everett contests that language must have discrete infinity, and that the Piraha language - which he claims lacks recursion - is in fact finite. He likens it to the finite game of Chess, which has a finite number of moves but is nevertheless very productive, with novel moves being discovered throughout history.
Recursion in plain English
Recursion is the process a procedure goes through when one of the steps of the procedure involves rerunning the procedure. A procedure that goes through recursion is said to be recursive. Something is also said to be recursive when it is the result of a recursive procedure.
To understand recursion, one must recognize the distinction between a procedure and the running of a procedure. A procedure is a set of steps that are to be taken based on a set of rules. The running of a procedure involves actually following the rules and performing the steps. An analogy might be that a procedure is like a menu in that it is the possible steps, while running a procedure is actually choosing the courses for the meal from the menu.
A procedure is recursive if one of the steps that makes up the procedure calls for a new running of the procedure. Therefore a recursive four course meal would be a meal in which one of the choices of appetizer, salad, entrée, or dessert was an entire meal unto itself. So a recursive meal might be potato skins, baby greens salad, chicken Parmesan, and for dessert, a four course meal, consisting of crab cakes, Caesar salad, for an entrée, a four course meal, and chocolate cake for dessert, so on until each of the meals within the meals is completed.
A recursive procedure must complete every one of its steps. Even if a new running is called in one of its steps, each running must run through the remaining steps. What this means is that even if the salad is an entire four course meal unto itself, you still have to eat your entrée and dessert.
The Jargon File is a glossary of hacker slang. The original Jargon File was a collection of hacker slang from technical cultures such as the MIT Artificial Intelligence Laboratory, the Stanford AI Lab , and others of the old ARPANET Artificial Intelligence/Lisp programming language/PDP-10 communities, including Bolt, Beranek and Newman, Carn... ) is the following "definition" of recursion.
The C Programming Language is a well-known computer science book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language .... ." The following index entry is found on page 269:
recursion 86, 139, 141, 182, 202, 269
This is a parody on references in dictionaries, which in some cases may lead to circular definition
Circular definition
A circular definition is one that assumes a prior understanding of the term being defined. By using the term being defined as a part of the definition, a circular definition provides no new or useful information; either the audience already knows the meaning of the term, or the definition is deficient in including the term to be defined in th... s among related words. Jokes often have an element of wisdom, and also an element of misunderstanding. This one is also the second-shortest possible example of an erroneous recursive definition of an object, the error being the absence of the termination condition (or lack of the initial state, if looked at from an opposite point of view). Newcomers to recursion are often bewildered by its apparent circularity, until they learn to appreciate that a termination condition is key. A variation is:
Recursion
If you still don't get it, see: "Recursion".
which actually does terminate, as soon as the reader "gets it".
A recursive acronym is an abbreviation that recursion in the expression for which it stands. The term was first used in print in April 1986.... s, such as GNU
GNU
GNU is a computer operating system composed entirely of free software. Its name is a recursive acronym for GNU's Not Unix; it was chosen because its design is Unix-like, but differs from Unix by being free software and containing no Unix code.... , PHP
PHP
PHP is a scripting language originally designed for producing dynamic web pages. It has evolved to include a command line interface capability and can be used in Standalone software Graphical user interface.... or HURD.
Recursion in mathematics
Recursively defined sets
Example: the natural numbers
The canonical example of a recursively defined set is given by the natural numbers:
1 is in
if n is in , then n + 1 is in
The set of natural numbers is the smallest set of real numbers satisfying the previous two properties.
Example: The set of true reachable propositions
Another interesting example is the set of all true "reachable" propositions in an axiomatic system
Axiomatic system
In mathematics, an axiomatic system is any Set of axioms from which some or all axioms can be used in conjunction to logically derive theorems.... .
if a proposition is an axiom, it is a true reachable proposition.
if a proposition can be obtained from true reachable propositions by means of inference rules, it is a true reachable proposition.
The set of true reachable propositions is the smallest set of reachable propositions satisfying these conditions.
This set is called 'true reachable propositions' because: in non-constructive approaches to the foundations of mathematics, the set of true propositions is larger than the set recursively constructed from the axioms and rules of inference. See also Gödel's incompleteness theorems
Gödel's incompleteness theorems
In mathematical logic, G?del's incompleteness theorems, proved by Kurt G?del in 1931, are two theorems stating inherent limitations of all but the most trivial formal systems for arithmetic of mathematical interest.... .
(Note that determining whether a certain object is in a recursively defined set is not an algorithmic task.)
The mathematical concept of a function expresses dependence between two quantities, one of which is known and the other which is produced. A function associates a single output to each input element drawn from a fixed Set , such as the real numbers , although different inputs may have the same output.... may be partly defined in terms of itself. A familiar example is the Fibonacci number
Fibonacci number
In mathematics, the Fibonacci numbers are a sequence of numbers named after Leonardo of Pisa, known as Fibonacci . Fibonacci's 1202 book Liber Abaci introduced the sequence to Western European mathematics, although the sequence had been previously described in Indian mathematics.... sequence: F(n) = F(n − 1) + F(n − 2). For such a definition to be useful, it must lead to values which are non-recursively defined, in this case F(0) = 0 and F(1) = 1.
In computability theory, the Ackermann function or Ackermann?P?ter function is a simple example of a computable function that is not Primitive recursive function.... which, unlike the Fibonacci sequence, cannot be expressed without recursion.
Recursive proofs
The standard way to define new systems of mathematics or logic is to define objects (such as "true" and "false", or "all natural numbers"), then define operations on these. These are the base cases. After this, all valid computations in the system are defined with rules for assembling these. In this way, if the base cases and rules are all proven to be calculable, then any formula in the mathematical system will also be calculable.
This sounds unexciting, but this type of proof is the normal way to prove that a calculation is impossible. This can often save a lot of time. For example, this type of proof was used to prove that the area of a circle is not a simple ratio of its diameter, and that no angle can be trisected
Angle trisection
The problem of trisecting the angle is a classic problem of compass and straightedge constructions of ancient Greek mathematics.Two tools are allowed... with compass and straightedge -- both puzzles that fascinated the ancients.
In mathematics and computer science, dynamic programming is a method of solving problems that exhibit the properties of overlapping subproblems and optimal substructure .... is an approach to optimization
Optimization (mathematics)
In mathematics, the simplest case of optimization, or mathematical programming, refers to the study of problems in which one seeks to maxima and minima or maxima and minima a Function of a real variable by systematically choosing the values of Real number or integer variables from within an allowed set.... which restates a multiperiod or multistep optimization problem in recursive form. The key result in dynamic programming is the Bellman equation
Bellman equation
A Bellman equation , named after its discoverer, Richard Bellman, is a necessary condition for optimality associated with the mathematical optimization method known as dynamic programming.... ,
which writes the value of the optimization problem at an earlier time (or earlier step)
in terms of its value at a later time (or later step).
Recursion in computer science
A common method of simplification is to divide a problem into subproblems of the same type. As a computer programming
Computer programming
Computer programming is the process of writing, testing, debugging/troubleshooting, and maintaining the source code of computer programs. This source code is written in a programming language.... technique, this is called divide and conquer
Divide and conquer algorithm
In computer science, divide and conquer is an important algorithm design paradigm based on multi-branched recursion. A divide and conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same type, until these become simple enough to be solved directly.... and is key to the design of many important algorithms, as well as being a fundamental part of dynamic programming
Dynamic programming
In mathematics and computer science, dynamic programming is a method of solving problems that exhibit the properties of overlapping subproblems and optimal substructure .... .
Recursion in computer programming is exemplified when a function is defined in terms of itself. One example application of recursion is in parsers for programming languages. The great advantage of recursion is that an infinite set of possible sentences, designs or other data can be defined, parsed or produced by a finite computer program.
In mathematics, a recurrence relation is an equation that defines a sequence recursion: each term of the sequence is defined as a Function of the preceding terms.... s are equations to define one or more sequences recursively. Some specific kinds of recurrence relation can be "solved" to obtain a non-recursive definition.
A classic example of recursion is the definition of the factorial
Factorial
In mathematics, the factorial of a negative and non-negative numbers integer n, denoted by n!, is the Product of all positive integers less than or equal to n.... function, given here in C code:
unsigned int factorial(unsigned int n)
The function calls itself recursively on a smaller version of the input (n - 1) and multiplies the result of the recursive call by n, until reaching the base case, analogously to the mathematical definition of factorial.
Use of recursion in an algorithm has both advantages and disadvantages. The main advantage is usually simplicity. The main disadvantage is often that the algorithm may require large amounts of memory if the depth of the recursion is very large. It has been claimed that recursive algorithms are easier to understand because the code is shorter and is closer to a mathematical definition , as seen in these factorial examples.
It is often possible to replace a recursive call with a simple loop, as the following example of factorial shows:
unsigned int factorial(unsigned int n)
It should be noted that on most CPUs the above examples give correct results only for small values of n, due to arithmetic overflow
Arithmetic overflow
The term arithmetic overflow or simply overflow has the following meanings.# In a digital computer, the condition that occurs when a calculation produces a result that is greater in magnitude than what a given processor register or Computer storage location can store or represent.... .
An example of a recursive algorithm is a procedure that processes (does something with) all the nodes of a tree data structure:
void ProcessTree(node x)
To process the whole tree, the procedure is called with a root node representing the tree as an initial parameter. The procedure calls itself recursively on all child nodes of the given node (i.e. sub-trees of the given tree), until reaching the base case that is a node with no child nodes (i.e. a tree having no branches known as a "leaf").
A tree data structure itself can be defined recursively (and so predestinated for recursive processing) like this:
Set theory is the branch of mathematics that studies Set , which are collections of objects. Although any type of object can be collected into a set, set theory is applied most often to objects that are relevant to mathematics.... , this is a theorem guaranteeing that recursively defined functions exist. Given a set , an element of and a function , the theorem states that there is a unique function (where denotes the set of natural numbers including zero) such that
for any natural number .
Proof of uniqueness
Take two functions and of domain and codomain such that:
where is an element of . We want to prove that . Two functions are equal if they:
Mathematical induction is a method of mathematical proof typically used to establish that a given statement is true of all natural numbers. It is done by proving that the first statement in the infinite sequence of statements is true, and then proving that if any one statement in the infinite sequence of statements is true, then... : for all in , ? (We shall call this condition, say, :
If and only if, in logic and fields that rely on it such as mathematics and philosophy, is a biconditional logical connective between statements.... if and only if .
2.Let be an element of . Assuming that holds, we want to show that holds as well, which is easy because: .
Proof of existence
See Hungerford, "Algebra", first chapter on set theory.
In mathematics, the factorial of a negative and non-negative numbers integer n, denoted by n!, is the Product of all positive integers less than or equal to n.... :
In combinatorics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involvingrecursion defined objects.... s: ,
Interest is a fee paid on borrowed assets. It is the price paid for the use of borrowed money , or, money earned by deposited funds .Assets that are sometimes lent with interest include money, shares, consumer goods through hire purchase, major assets such as aircraft finance, and even entire factories in finance lease arrangements....
The Tower of Hanoi or Towers of Hanoi is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod....
In computability theory, the Ackermann function or Ackermann?P?ter function is a simple example of a computable function that is not Primitive recursive function....
Population growth rate
Odds of a shared birthday among a group of people.