[motivation]
### From formulas to arbitrary assignments
For most of the eighteenth century, a "function" meant a formula — an algebraic expression like $y = x^3 - 7x + 2$ or a trigonometric one like $y = \sin(x)$. Euler's original definition required that a function be given by a single analytic expression. This restriction was natural in an era when calculus was the study of curves, and curves were the graphs of formulas.
The decisive break came with Fourier's work on heat conduction in 1807. Fourier claimed that an "arbitrary" function — even one defined piecewise, such as a function that equals $1$ on $[0, 1]$ and $0$ on $(1, 2]$ — could be represented by a trigonometric [series](/page/Series). His contemporaries found this deeply suspect, and the ensuing debate forced mathematicians to confront the question: what, exactly, is a function?
Dirichlet's answer, given in 1837, was radical in its generality. A function from a set $X$ to a set $Y$, he proposed, is any rule that assigns to each element of $X$ a single element of $Y$. No formula is required. The assignment can be completely arbitrary — the only constraint is that each input produces exactly one output. This is the definition we formalise below.
### Why domain and codomain matter
Consider the formula $f(x) = x^2$. Interpreted as a function $f \colon \mathbb{R} \to \mathbb{R}$, it is neither injective (since $f(-2) = f(2) = 4$) nor surjective (since $-1$ has no preimage). Interpreted as a function $f \colon [0, \infty) \to [0, \infty)$, it is both injective and surjective — a bijection. The formula has not changed, but the function has, because a function is not just a rule; it is a rule together with a specified domain and codomain. As we will see, injectivity, surjectivity, the existence of inverses, and even cardinality arguments all depend critically on the choice of domain and codomain.
### The power of abstraction
Once we have the general definition of a function, powerful questions become available. When are two functions "the same"? The answer — when they have the same domain, the same codomain, and the same value at every point — is the principle of extensionality. When does a function have an inverse? Precisely when it is a bijection. And once we can compose functions and take inverses, we can ask which functions preserve mathematical structure. This last question leads to homomorphisms of groups, [continuous](/page/Continuity) maps of topological spaces, and [linear maps](/page/Linear%20Map) of vector spaces — the morphisms that form the backbone of modern mathematics.
[/motivation]