What Is a Function? A Rule That Never Gives Two Answers
By the BrainSnail editorial team. How these articles are written and checked, and how to tell us when one is wrong.
A function assigns exactly one output to each input, and that single restriction is what makes the idea useful. Without it nothing could be computed, plotted or composed reliably, and with it an enormous range of apparently unrelated things turn out to be the same kind of object.
The definition and why it is fussy
A function consists of three things: a set of permitted inputs called the domain, a set the outputs come from called the codomain, and a rule pairing each input with exactly one output. The requirement of exactly one is the whole content. A rule assigning two outputs to an input is a relation and not a function, which is why the equation of a circle does not define a single function of one variable and must be split into two. Specifying the domain is not pedantry, since the same formula defines different functions on different domains and questions about whether a function is invertible or continuous depend on it. The modern definition treats a function as a set of ordered pairs rather than as a formula, which detaches the idea from any expression and allows functions that no formula describes, and that abstraction was hard won, since earlier mathematicians assumed a function must be given by an expression and were forced to generalise by problems in analysis.
The vocabulary
A small number of properties classify functions and each answers a practical question:
- •Injective, meaning no two inputs share an output, which is what allows the process to be reversed without ambiguity
- •Surjective, meaning every element of the codomain is hit by something, which is about whether the range fills the target
- •Bijective, meaning both, which is exactly the condition for an inverse function to exist
- •Composition, applying one function to the output of another, which is associative and is the basis of building complex operations from simple ones
- •Continuity, meaning small changes in input produce small changes in output, which is what makes approximation and prediction possible
- •The vertical line test, which is the graphical version of the exactly-one requirement, since a vertical line meeting a graph twice shows two outputs for one input
How general the idea is
Once the definition is detached from formulas, a great many things become functions. A sequence is a function from the counting numbers. A matrix defines a function between spaces of vectors. A computer program that always produces the same output for the same input is a function, and the entire paradigm of functional programming takes that seriously by building languages around functions without side effects, which makes reasoning about programs far easier. A probability distribution is a function. A physical law relating quantities is a function. Encryption is a function chosen to be extremely difficult to invert. Database lookups, dictionary structures and lookup tables are functions represented explicitly rather than by rule. The recurring benefit of recognising something as a function is that all the machinery developed for functions, including composition, inversion and continuity, becomes available at once, which is what mathematical abstraction is for.
Where the confusion comes from
Several persistent difficulties in learning the concept have identifiable sources. Notation conflates the function with its value, since the same symbol frequently denotes both the rule and the output, which is a genuine ambiguity in standard usage. Graphs encourage thinking of a function as a curve, which makes functions on discrete domains or between abstract sets hard to picture. School treatment emphasises formulas, which builds the expectation that a function is an expression and makes the general definition feel arbitrary. Multivalued cases, including square roots and inverse trigonometric functions, are handled by convention rather than by the definition, so the principal value is chosen and the choice is rarely explained. And the word is used loosely outside mathematics for any dependence at all, which conflicts with the strict sense. Each of those is worth naming explicitly, since the concept is a prerequisite for nearly everything that follows and confusion about it propagates.
The takeaway
Exactly one output per input is the entire requirement, and it is what allows reversal, composition and computation to work reliably. Specifying the domain is part of the definition rather than a detail. Treating a function as a set of pairs rather than a formula was a hard-won generalisation that admits functions no expression describes, and it is why sequences, programs, matrices and encryption are all the same kind of object.