A **function** is a relation between a set of inputs (called the **domain**), and a permissible set of outputs (called the **codomain**), such that each input is is related to exactly one output. We often denote a function on 1 variable by $f$. When $x$ is an element of the domain, we say that the output has the value $f(x)$.

Note that the domain, and codomain, need not always be the set of real numbers. Other common sets that are used are the complex numbers, positive integers, people, matrices, graphs, etc. For example, we can have a function $Citizen (\cdot)$, which given the name of a Brilliant student, tells us the country that the student is a citizen of. In this case, the domain is the set of names of Brilliant students, while the codomain is the set of countries. In order for this to be truly a function, we must make the assumption that a student is a citizen of only 1 country. In order to deal with the possibility of dual citizenships, we must add pairs of countries to our codomain.

We can certainly add irrelevant items to the codomain, like {alligator}, {purple} and {Calvin}. As such, we define the **range** of a function (also called the **image**) to be the set of all outputs. Note that by definition, the range of a function has to be a subset of the codomain.

The mathematical shorthand (since mathematicians are lazy) to state that $f$ is a function from set $A$ to set $B$ is $f: A \rightarrow B$. For example, since $\mathbb{C}$ stands for complex numbers, and $\mathbb{Z}$ stands for integers, $\mathbb{N}$ stands for positive integers, so $f : \mathbb{C} \rightarrow \mathbb{N}$ refers to a function from the set of complex numbers to the set of positive integers. Because we mainly deal with functions of real numbers, if the domain and codomain are not explicitly stated (or immediately obvious from the setup), they are assumed to be the set of real numbers,

While it is common for the domain and codomain to be the same set, it is important to make a clear distinction between the two. The identity function is the unique function on a set, which maps every element to itself. We denote this function be $Id_A : A \rightarrow A$, where $Id_A (a) = a$ for all elements $a$ of $A$.

If we were to change the domain of a function, then we will get a different function. For example, $Id_\mathbb{R} : \mathbb{R} \rightarrow \mathbb{R}$ is a very different function from $Id_\mathbb{N} : \mathbb{N} \rightarrow \mathbb{N}$. This is because we have $Id_\mathbb{R} (0.5) = 0.5$, while $Id_\mathbb{N} (0.5)$ does not make any sense. As such, we say that 2 functions $f: A \rightarrow B$ and $g: C \rightarrow D$ are equal if $A=C$ and for all values $a$ in $A$, $f(a) = g(a)$. The codomain is less important, since by our previous observation we can add arbitrary elements to it while not affecting the essence of the function.

Given a function $f: A \rightarrow B$ and any subset $C \subset A$, we say that the image of $C$ is the set of all values $f(c)$, where $c$ is an element of $C$. Given a subset $D \subset B$, we say that the preimage of $D$ is the set of all values $x$ where $f(x)$ is an element of $D$. Using this terminology, we say that the range is the image of the domain. Essentially, the range is the part of the codomain that we really care about, which is why we will like to restrict our attention to just the range.

When the domain is the set of real numbers, we like to think of $f(x)$ as the graph of the function. Conversely, given any graph, it is a function if each x-value corresponds to at most 1 y-value. Such a graph must pass the vertical line test: Every vertical line cuts the graph in at most 1 point.

What if we want to find all possible inputs, which give a certain output? For example, if I want to know who are all the Brilliant students that are citizens of India, I am asking for the list of students who satisfy $Citizen (\cdot) =$ India. The inverse of a function, need not always be a function (as in this example). In order for an inverse to be an actual function, the original function needs to pass the horizontal line test: Every horizontal line cuts the graph in at most 1 point.

If the inverse is a function, we denote it as $f^{-1}$. What is the domain and codomain of $f^{-1}$? Can we take the inverse of any value in the codomain? We certainly could, though it might not make sense. For example, $Citizen^{-1} (Calvin)$ would not be valid. As such, we often restrict our attention to simply the range of the original function (which, as you recall, is the image of the domain). What is the codomain of the inverse? It would be the pre-image of the range. Note that the pre-image of the range need not be the entire domain of $f$.

In the event that the inverse is not a function, we can restrict our attention to a subset of the domain. Specifically, if $f: A \rightarrow B$, and $C \subset A$, we define the function $f|_C : C \rightarrow B$ as $f|_C (c) = f(c)$ for all values $c$ in $C$. For example, the function $S : \mathbb{R} \rightarrow \mathbb{R}$ given by $S(x) = x^2$ does not have an inverse function because it doesn't satisfy the horizontal line test. However, since $S|_{\mathbb{R}^{\leq 0}}$ does satisfy the horizontal line test, it has an inverse. In this case, we know that $S|_{\mathbb{R}^{\leq 0}} ^{-1} (x) = -\sqrt{x}$.

A function is **injective** (or one-to-one) if $f(a_1) \neq f(a_2)$ for any 2 distinct elements $a_1, a_2$ in the domain. A function is **surjective** (or onto) if for every element $b$ in the codomain, there exists an element $a$ in the domain such that $f(a) = b$. A function is bijective if it is both injective and surjective. With this terminology, an injective function has an inverse that is a function. A bijective function $f: A \rightarrow B$ has an inverse (which is a function by the previous observation) whose domain is $B$.

Now that we've build up this vocabulary, we can talk about the **composition** of functions. You may not always be able to compose 2 functions. For example, $Citizen \circ Citizen$ will not make any sense, no matter what we try to do. Let's understand how to make composition of functions work.

Assuming that we have 2 functions $f : A \rightarrow B$ to be a function, $g: C \rightarrow D$, when does $g \circ f$ make sense? Given any value $a$ in the domain A, we must be able to apply $g$ to the value $f(a)$. Hence, this implies that $B$ must be a subset of $C$. With this condition, we can define $g \circ f: A \rightarrow D$ to be equal to $(g \circ f) (a) = g ( f(a) )$. Note that the order of composition is important, since we might not be able to define $f \circ g$, unless we further know that $D$ is a subset of $A$.

No vote yet

1 vote

Easy Math Editor

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

`*italics*`

or`_italics_`

italics`**bold**`

or`__bold__`

boldNote: you must add a full line of space before and after lists for them to show up correctlyparagraph 1

paragraph 2

`[example link](https://brilliant.org)`

`> This is a quote`

Remember to wrap math in`\(`

...`\)`

or`\[`

...`\]`

to ensure proper formatting.`2 \times 3`

`2^{34}`

`a_{i-1}`

`\frac{2}{3}`

`\sqrt{2}`

`\sum_{i=1}^3`

`\sin \theta`

`\boxed{123}`

## Comments

There are no comments in this discussion.