Functions, Domains, and Codomains
Section titled βFunctions, Domains, and CodomainsβDefinition. A function assigns each element of the input set to exactly one element of the output set . The set is the domain, and the set is the codomain.
A function can be pictured as a machine or an arrow diagram, but the important rule is simple: every input gets exactly one output. Different inputs are allowed to share an output. What is not allowed is one input being sent to two different outputs.
The notation
specifies three pieces of information:
- the rule or assignment ,
- the domain ,
- the codomain .
All three are part of the function. A formula by itself is not enough because its behavior depends on which inputs are allowed and which outputs are expected.
The expression is the output assigned to the input . The set of outputs the function actually reaches is its image or range:
The codomain is part of the functionβs definition. Two rules with the same formula but different domains or codomains are different functions.
Example. Let be defined by . Identify its domain, codomain, and image, and evaluate .
The domain and codomain come from the declaration , so both are . Substituting gives
Although the codomain is all real numbers, a real square cannot be negative. Every nonnegative real number does occur as a square, so
Thus, the image can be smaller than the codomain.
The image of a set of inputs is also useful. If , then
For the squaring function above,
The interval crosses , so the smallest output is ; the input with the largest magnitude is , which gives the largest output .
Images behave predictably with unions. If , then
An output is on the left exactly when it comes from an input in or an input in , which is exactly what the right side says.
For intersections, only one direction is always guaranteed:
If an input belongs to both sets, its output certainly belongs to both images. The reverse direction can fail because two different inputs may produce the same output.
Example. Let be given by , and set
Their intersection is , so
However,
and therefore
The output belongs to both images, but it comes from in the first set and in the second. There is no common input producing it. If is injective, this kind of collision cannot happen, and equality does hold for intersections.
Functions as sets of ordered pairs
Section titled βFunctions as sets of ordered pairsβThere is also a formal set-based definition of a function. A function is a subset of the Cartesian product in which every element of appears exactly once as a first coordinate. The ordered pair means that .
This definition captures both requirements at once: every input must appear, and it must appear with only one output. A general subset of is called a relation. A relation becomes a function only when it satisfies the exactly-one-output condition.
Example. Let and . The relation defined by is
This relation is not a function from to . The input appears with three different second coordinates, so it would have three outputs. By contrast, the identity function on lives in and is the set
where each input appears exactly once.
Definition. Functions and are equal if
and
The identity function on a set is
It leaves every element unchanged.
Identity functions may look trivial, but they give a reference point for what it means to leave a space unchanged. Later, composing a function with will play the same role as multiplying a number by .
Example. Define by and by . Determine whether .
The formulas agree wherever both functions are defined, but the domains do not:
Therefore, and are different functions.
Well-Defined Functions
Section titled βWell-Defined FunctionsβA proposed function must give one unambiguous output for every input in its domain. This can fail in three main ways: an input has no output, an input has more than one output, or a single mathematical object has several representations and the rule depends on which representation is chosen.
For example, the rule does not define a function because the allowed input has no real output. It does define a function
because removing from the domain removes the problem.
Example. Consider the proposed rule given by
Determine whether is well-defined.
The same rational number can be written in different ways. For example,
but the rule gives
and
One input would have two outputs, so the rule is not well-defined. To repair it, one could require a unique standard representation: must be in lowest terms and . Requiring lowest terms alone is not quite enough because
still gives two reduced representations unless the sign convention is fixed.
Every sequence is a function whose domain is usually . A sequence can be written as
For example, the sequence
is the function
The input is the position in the sequence, and the output is the term at that position. Thinking of sequences as functions lets the same definitions of image, injectivity, and composition apply to them later.
Injective, Surjective, and Bijective Functions
Section titled βInjective, Surjective, and Bijective FunctionsβThese three words describe how the arrows from the domain land in the codomain:
| Property | What can go wrong? | Informal picture |
|---|---|---|
| Injective | Two inputs collide at one output | no collisions |
| Surjective | A codomain element is never reached | no gaps |
| Bijective | Neither problem occurs | perfect pairing |
Definition. A function is injective or one-to-one if different inputs always have different outputs:
Equivalently,
The two injectivity statements are contrapositives, so they are logically equivalent. In proofs, the second form is usually easier: assume two outputs are equal, then show the inputs must have been equal.
For a real-valued graph, injectivity is checked by the horizontal line test: every horizontal line may intersect the graph at most once.
Definition. A function is surjective or onto if every element of the codomain is reached:
Surjectivity compares the image with the stated codomain:
This is why changing only the codomain can change whether a function is onto. The outputs do not change, but the target the function is expected to cover does.
A function that is both injective and surjective is bijective. A bijection pairs every input with exactly one output and reaches every element of the codomain.
A bijection is reversible: every output points back to exactly one input. This is the reason bijections are used to compare the sizes of sets and why invertible linear transformations become so important later.
Example. Classify each version of the squaring rule as injective, surjective, both, or neither:
where each function sends to .
The function is not injective because
It is not surjective because no negative real number is an output. Thus, is neither.
Restricting the domain removes the collision between positive and negative inputs, so is injective. Its codomain is still , however, so it still misses every negative number and is not surjective.
The function uses the restricted domain and the exact image as its codomain. It is injective and surjective, so it is bijective.
Proof (A bijection on the rational numbers). Define by
To prove injectivity, suppose . Then
so .
To prove surjectivity, let . Choose
Since rational numbers are closed under subtraction and division by a nonzero rational number, . Moreover,
Thus, is both injective and surjective, so it is bijective.
Example. Let be defined by
Determine whether is injective or surjective.
It is not injective because distinct complex numbers can have the same magnitude. For example,
It is also not surjective onto because magnitudes are never negative. In particular, there is no such that .
Restricting a domain
Section titled βRestricting a domainβA function that is not injective on its full domain may become injective after the domain is restricted. The restriction must remove every repeated output, not just some of them.
Example. Let
be defined by . Determine whether is bijective.
On the interval , cosine increases from to without reversing direction. Therefore, no horizontal line meets this part of the graph more than once, so is injective.
Every value between and occurs as cosine moves continuously from to . Thus,
which equals the codomain. The function is also surjective, so it is bijective.
Restricting the domain carelessly may not work. For example, is still not injective on
because both and remain in the domain whenever . A restriction makes a function injective only if each output is left with at most one input.
Function Composition
Section titled βFunction CompositionβFunctions can be connected so that the output of one becomes the input of another. If
then the composition of with is the function
defined by
The rightmost function acts first: begin with , apply , and then apply to the result. The codomain of must fit the domain of so that the second step is meaningful.
Example. Let be defined by
For , apply first:
For , apply first:
The two compositions are different. For instance,
Thus, function composition is generally not commutative: changing the order can change the result.
Although composition is not usually commutative, it is associative.
Proof (Associativity of function composition). Suppose
For every ,
On the other hand,
The two functions have the same domain, codomain, and output at every input, so
The identity function behaves like doing nothing before or after a function:
for every . Also, the composition of two bijections is again a bijection, so several reversible steps can be joined into one reversible process.
Inverse Functions
Section titled βInverse FunctionsβAn inverse function reverses another function. If , an inverse of is a function satisfying both
and
The first identity says that starting in , moving backward with , and then forward with returns to the original element. The second says the same thing for an element that starts in . When an inverse exists, it is unique and is written .
Theorem. A function is invertible if and only if it is bijective.
Proof. First suppose has an inverse . If , applying gives
so . Thus, is injective. For any , choose . Then
so is surjective.
Conversely, suppose is bijective. For each , surjectivity guarantees at least one with , and injectivity guarantees that this is unique. Define to be that unique input. Then and , so .
This theorem explains both possible failures of reversibility. If a function is not injective, one output does not reveal which input produced it. If it is not surjective, some element of the codomain has no input to return to.
Example. The bijection defined by
has an inverse. To find it, set and solve for :
Therefore,
Checking both directions gives
and
The squaring rule on all of has no inverse because it is not injective. After restricting it to
it becomes bijective, and its inverse is
The domain restriction is not a technical detail: it is what makes each nonnegative output point back to exactly one input.
Preimages of sets
Section titled βPreimages of setsβThe notation is also used for the preimage of a subset :
A preimage asks which inputs land inside a chosen set of outputs. It exists for every function; does not need to be invertible. The context makes clear whether means an inverse function or the preimage operation on sets.
Preimages preserve both unions and intersections exactly:
and
There is no injectivity requirement here. A single input has only one output, so checking whether that output belongs to both target sets creates no ambiguity.
Example. Let be defined by . Find the preimage of .
We need all real inputs whose squares lie between and :
This occurs when , so
The function itself is not invertible on , but the preimage of a set is still perfectly well-defined.
Functions Beyond Real-Valued Formulas
Section titled βFunctions Beyond Real-Valued FormulasβMany important functions in linear algebra take vectors, matrices, or even other functions as inputs. What matters is not whether there is a familiar algebraic formula, but whether every allowed input receives exactly one output in the stated codomain.
Example. Let be the set of polynomials with real coefficients, and define the derivative operator
This function is not injective because different polynomials can have the same derivative. For example,
It is surjective. If
then the polynomial
satisfies . In other words, every polynomial has a polynomial antiderivative.
If the domain is restricted to polynomials satisfying , the arbitrary constant is fixed. On that restricted domain, differentiation becomes bijective, with inverse
Example. Define by
This function is not injective because, for example,
It is surjective because any real number is the output of the input :
This example also shows that having more input coordinates does not prevent a function from being onto a smaller-looking codomain.
Example. The trace function sends a square matrix to the sum of its diagonal entries:
It is surjective: for any , the diagonal matrix with first diagonal entry and all other entries has trace .
It is not injective because many matrices have the same trace. For example, when ,
Trace keeps one useful number while discarding most of the information in the matrix. This is a common theme: a function can compress a complicated object into a simpler output without being reversible.