Functions and Inverses
students, imagine a machine at a school printer: you put in one specific input, and the machine gives one output. That is the heart of a function 🖨️. In discrete mathematics, functions help us describe rules, encode information, and study how one set connects to another. In this lesson, you will learn what functions are, how to test whether a rule is a function, what an inverse means, and when an inverse exists. You will also see how these ideas fit into the bigger picture of sets, functions, and relations.
What a Function Is
A function is a special kind of relation between two sets. If $A$ and $B$ are sets, a function $f$ from $A$ to $B$ is written as $f: A \to B$. It assigns each element of $A$ to exactly one element of $B$.
The set $A$ is called the domain, and the set $B$ is called the codomain. The set of actual outputs is called the range or image.
This “exactly one output” idea is the key rule. If an input has no output, or has two different outputs, then the rule is not a function.
Example: suppose $f(x) = x + 3$ with domain $\{1,2,3\}$. Then:
- $f(1) = 4$
- $f(2) = 5$
- $f(3) = 6$
Each input has one output, so this is a function ✅.
Now compare that with a rule that says “send $x$ to both $x+1$ and $x+2$.” For $x=1$, the outputs would be $2$ and $3$. That is not a function because one input would have two outputs.
Functions are used everywhere in real life. A student ID number can map to one student record. A calculator uses a rule to change one number into another. In computer science, functions are often used to transform data.
Ways to Describe a Function
A function can be described in several ways:
- Formula: such as $f(x) = 2x - 1$
- Table: a list of input-output pairs
- Mapping diagram: arrows from elements of one set to another
- Graph: points showing the relationship between inputs and outputs
Example table:
| $x$ | $f(x)$ |
|---|---|
| $1$ | $3$ |
| $2$ | $5$ |
| $3$ | $7$ |
This table represents $f(x) = 2x + 1$ on the domain $\{1,2,3\}$.
A graph can also help you decide whether something is a function. A vertical line should not hit the graph more than once if the graph is of a function. This is called the vertical line test. If a vertical line crosses the graph in two places, then one $x$ value has more than one $y$ value, so the relation is not a function.
Important Function Terms
Here are a few terms you need to know:
- Domain: all allowed inputs
- Codomain: the set of possible outputs
- Range: outputs that actually occur
- Image of an element: the output for a specific input
- Preimage: an input that gives a particular output
If $f(a) = b$, then $b$ is the image of $a$, and $a$ is a preimage of $b$.
Example: if $f(x) = x^2$ and the domain is $\{-2,-1,0,1,2\}$, then the range is $\{0,1,4\}$. Notice that $4$ appears only once in the range even though two different inputs, $-2$ and $2$, both map to it. That is allowed in a function. Different inputs may share the same output.
This is an important point: a function must give one output to each input, but it does not have to give different outputs to different inputs.
One-to-One and Onto
Some functions have extra properties that matter a lot when studying inverses.
A function is one-to-one or injective if different inputs always produce different outputs. In symbols, if $f(a) = f(b)$, then $a = b$.
Example: $f(x) = 2x + 1$ is one-to-one. If $2a + 1 = 2b + 1$, then $a = b$.
A function is onto or surjective if every element of the codomain is hit by at least one input. That means the range equals the codomain.
Example: if $f: \{1,2,3\} \to \{a,b,c\}$ is defined by $f(1)=a$, $f(2)=b$, and $f(3)=c$, then every element of the codomain has a preimage, so the function is onto.
A function that is both one-to-one and onto is called bijective. Bijective functions are exactly the functions that have inverses. This is the most important fact in this lesson 🔑.
What an Inverse Function Means
An inverse function “undoes” the original function. If $f$ sends $x$ to $y$, then the inverse function $f^{-1}$ sends $y$ back to $x$.
If $f(a) = b$, then $f^{-1}(b) = a$.
Be careful: $f^{-1}(x)$ is not the same as $\frac{1}{f(x)}$. The notation $f^{-1}$ means inverse function, not reciprocal.
Example: let $f(x) = x + 4$. To find the inverse, start with $y = x + 4$ and solve for $x$:
$$y = x + 4$$
$$x = y - 4$$
So the inverse is $f^{-1}(x) = x - 4$.
Check it:
- $f(7) = 11$
- $f^{-1}(11) = 7$
The two functions reverse each other.
How to Find an Inverse
To find the inverse of a function given by a formula, follow these steps:
- Write $y = f(x)$
- Swap the roles of $x$ and $y$
- Solve for $y$
- Rename $y$ as $f^{-1}(x)$
Example: find the inverse of $f(x) = 3x - 2$.
Start with:
$$y = 3x - 2$$
Swap $x$ and $y$:
$$x = 3y - 2$$
Solve for $y$:
$$x + 2 = 3y$$
$$y = \frac{x+2}{3}$$
So,
$$f^{-1}(x) = \frac{x+2}{3}$$
Now check both compositions:
$$f\left(f^{-1}(x)\right) = x$$
and
$$f^{-1}(f(x)) = x$$
These identities show that the inverse really undoes the original function.
When an Inverse Exists
Not every function has an inverse function. To have an inverse function, the original function must be bijective.
Why? If a function is not one-to-one, then two different inputs can lead to the same output. When you try to reverse it, one output would point back to more than one input, which is not allowed for a function.
Example: $f(x) = x^2$ on all real numbers is not one-to-one because $f(2) = 4$ and $f(-2) = 4$. If you try to make an inverse, the result would be $x = \pm\sqrt{y}$, which gives two answers. That is not a function.
However, if you restrict the domain to nonnegative numbers, such as $x \ge 0$, then $f(x)=x^2$ becomes one-to-one. Its inverse is $f^{-1}(x)=\sqrt{x}$ for $x \ge 0$.
This shows that the domain matters a lot. A function may not have an inverse on one domain, but it may have one after restriction.
Functions, Relations, and the Bigger Picture
In discrete mathematics, a relation from $A$ to $B$ is any collection of ordered pairs in $A \times B$. A function is a special relation with exactly one output for each input.
So the relationship is:
- Every function is a relation
- Not every relation is a function
- A function may have an inverse only if it is bijective
This is why functions and inverses fit neatly into the larger study of sets and relations. Sets give us the objects, relations describe possible pairings, and functions add a strict rule about how pairing works.
Example: let $R = \{(1,a),(1,b),(2,c)\}$. This is a relation, but not a function, because input $1$ has two outputs.
Now compare with $f = \{(1,a),(2,c),(3,b)\}$. This is a function. If the codomain is $\{a,b,c\}$, then it is also bijective, so it has an inverse relation that is also a function.
Conclusion
students, functions are one of the most important ideas in discrete mathematics because they connect sets in a controlled way. A function gives exactly one output for each input. Some functions are one-to-one, some are onto, and the functions that are both are bijective. Only bijective functions have inverse functions, which reverse the original mapping. These ideas help you reason about data, rules, and structure in mathematics, computer science, and many real-world systems. If you remember the core idea “one input, one output,” you already understand the foundation 🌟.
Study Notes
- A function $f: A \to B$ assigns each input in $A$ exactly one output in $B$.
- $A$ is the domain, $B$ is the codomain, and the range is the set of actual outputs.
- A relation is any set of ordered pairs, but a function must give each input exactly one output.
- The vertical line test helps check whether a graph represents a function.
- A function is one-to-one if different inputs never share the same output.
- A function is onto if every element of the codomain is matched by at least one input.
- A function is bijective if it is both one-to-one and onto.
- A function has an inverse function only if it is bijective.
- The inverse function $f^{-1}$ reverses the action of $f$.
- To find an inverse, write $y = f(x)$, swap $x$ and $y$, then solve for $y$.
- For inverse functions, $f\left(f^{-1}(x)\right) = x$ and $f^{-1}(f(x)) = x$.
- The notation $f^{-1}(x)$ means inverse function, not reciprocal.
