Mathbook: Introduction to Functions

(Edit, 10/29) This post has been ported to a math-focused blog here. The goal of the change is improved typesetting for me, and improved readability and interaction for you. See this post for more information.


This is the next post in the series of posts inspired by my brief work for Mathbook. Previously, we talked about sets. Once we have this basic object, we can start to create, define and communicate relationships and patterns between sets. Mathematics uses the language of a function to describe these relationships.

Most simply, a function is a rule that takes elements of one set (often called inputs) and assigns them to elements of another set (often called outputs.) The one rule to remember to make sure you have a function is a function only has a single output for each input.
Let’s first look at a simple example of a function, where we take elements in the set S = \{1,2,3\}, and assign them to another set F = \{\text{apples },\text{bananas }, \text{strawberries}\}, according to the following set of rules.
1 \to \text{bananas}
2\to \text{strawberries}
3\to \text{apples}
There are many notations used to discuss functions. The most common, and the one used by this tutorial, will be the form f:A\to B. We call f the function, where it takes elements from the set A and assigns them to elements in the set B. So, we could call the function above g: S\to F. While the letter used to name the function can be arbitrary, it is common to use f, g, or h if no other information is given.
It is good to have a common language to describe the sets A and B in the context of a function.


Definition

Domain: Given the function f: A\to B, we call the set A the domain of the function f. It can be thought of as the collection of possible inputs to the function.
Codomain: Given the function f:A\to B, we call the set B the codomain of the function f. The codomain is the set that contains all possible outputs. The set of possible outputs is thus a subset of the codomain.


Let’s look at the function from before, g: S\to F. Then S is the domain, and F is the codomain.
Imagine you wanted to tell a friend that our function g took the input 2 and assigned it to strawberries, but did not want to copy down the list of rules each time. This may not seem like a big deal, but imagine you had a domain with 1,000 elements. The need for an easy notation becomes apparent.
The accepted notation to tell our friends that g sends 2 to strawberries is g(2) = \text{strawberries}. This is most commonly read as “g of 2 equals strawberries.” This notation is very flexible, as it allows us to have more than one element as the input. For example, since the subset \{1,3\} \subset S has elements assigned to \{\text{bananas},\text{ apples}\}\subset F, we can say
g(\{1,3\}) = \{\text{bananas},\text{ apples}\}.
Remember that a set does not have its elements in a specific order, so we can also write
g(\{1,3\}) = \{\text{apples, }\text{bananas}\}.
Given just the above, we cannot tell exactly what f(1) and f(3) are; if we need to communicate that information, we can list them. But there are often situations where you just need to know if a particular element (often 0 or 1) is in the output of a set of inputs.


Definition

Function Notation: Given the function f:A\to B, where a\in A is assigned to the element b\in B, we write f(a) = b, said as “f of a is equal to b.” Similarly, if A_1\subset A is some subset of A such that the elements of A_1 are assigned exactly to elements in some B_1\subset B, we write f(A_1) = B_1.


As noted before, given the function f:A\to B, there is no guarantee that every element in B is actually an output of the function. We are only guaranteed that B contains every output. So, it is then natural to wonder what exactly f(A) is. Since A is the domain (set of possible inputs) of f, every element in A is assigned to some element in B. So, f(A) must be the set of all possible outputs for the function.


Definition

Range: The range of a function f (also commonly called the image) is defined to be the set f(A), or the set of all possible outputs of the function.


Since all possible outputs must exist in the codomain B, for any function f:A\to B we must have f(A)\subset B. For example, let’s introduce another set X = \{w, x, y, z\}, and we will define a new function h:S\to X by the set of rules
h(1) = w,\quad h(2) = y,\quad h(3) = z.
Then, h(S) = h(\{1, 2, 3\}) = \{w, y, z\} \subset X. So, the range of the function does not have to be equal to the codomain.
It is good to notice that a function can assign different inputs to the same outputs. For example, we can define a function p:S\to \{1\} by
p(1)=1,\quad p(2) = 1,\quad p(3)=1.

Exercises

Consider the function g:\{1,2\} \to \{1,2,3\} defined by g(1) = 3 and g(2)=1.

  1. What is the cardinality of the domain of g?
  2. What is the codomain of g?
  3. What is the image of g?
  4. Challenge: How many ways can we define a function h:\{1,2\} \to \{1,2,3\} so that every input is sent to a different output.

Note: A function where every input is sent to a different output is called one-to-one or injective, which will be discussed at a later time.

Leave a Reply