Skip to main content
Mathematics LibreTexts

8.1: Introduction to Functions

  • Page ID
    95455
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    In this chapter, we will introduce the concept of function as a special type of relation. Our definition should agree with any previous definition of function that you may have learned. We will also study various properties that a function may or may not possess.

    Up until this point, you may have only encountered functions as an algebraic rule, e.g., \(f(x)=x^{2}-1\), for transforming one real number into another. However, we can study functions in a much broader context. The basic building blocks of a function are a first set and a second set, say \(X\) and \(Y\), and a “correspondence” that assigns every element of \(X\) to exactly one element of \(Y\). Let’s take a look at the actual definition.

    Definition 8.1. Let \(X\) and \(Y\) be two nonempty sets. A function \(f\) from \(X\) to \(Y\) is a relation from \(X\) to \(Y\) such that for every \(x\in X\), there exists a unique \(y\in Y\) such that \((x,y)\in f\). The set \(X\) is called the domain of \(f\) and is denoted by \(dom(f)\). The set \(Y\) is called the codomain of \(f\) and is denoted by \(codom(f)\) while the subset of the codomain defined via \[\range(f):= \{y\in Y\mid \mbox{there exists }x\mbox{ such that } (x,y)\in f\}\] is called the range of \(f\) or the image of \(X\) under \(f\).

    There is a variety of notation and terminology associated to functions. We will write \(f:X\to Y\) to indicate that \(f\) is a function from \(X\) to \(Y\). We will make use of statements such as “Let \(f:X\to Y\) be the function defined via…" or “Define \(f:X\to Y\) via…", where \(f\) is understood to be a function in the second statement. Sometimes the word mapping (or map) is used in place of the word function. If \((a,b)\in f\) for a function \(f\), we often write \(f(a)=b\) and say that “\(f\) maps \(a\) to \(b\)” or “\(f\) of \(a\) equals \(b\)". In this case, \(a\) may be called an input of \(f\) and is the preimage of \(b\) under \(f\) while \(b\) is called an output of \(f\) and is the image of \(a\) under \(f\). Note that the domain of a function is the set of inputs while the range is the set of outputs for the function.

    According to our definition, if \(f:X\to Y\) is a function, then every element of the domain is utilized exactly once. However, there are no restrictions on whether an element of the codomain ever appears in the second coordinate of an ordered pair in the relation. Yet if an element of \(Y\) is in the range of \(f\), it may appear in more than one ordered pair in the relation.

    It follows immediately from the definition of function that two functions are equal if and only if they have the same domain, same codomain, and the same set of ordered pairs in the relation. That is, functions \(f\) and \(g\) are equal if and only if \(dom(f)=dom(g)\), \(codom(f)=codom(g)\), and \(f(x)=g(x)\) for all \(x\in X\).

    Since functions are special types of relations, we can represent them using digraphs and graphs when practical. Digraphs for functions are often called function (or mapping) diagrams. When drawing function diagrams, it is standard practice to put the vertices for the domain on the left and the vertices for the codomain on the right, so that all directed edges point from left to right. We may also draw an additional arrow labeled by the name of the function from the domain to the codomain.

    Example 8.2. Let \(X=\{a,b,c,d\}\) to \(Y=\{1,2,3,4\}\) and define the relation \(f\) from \(X\) to \(Y\) via \[f=\{(a,2),(b,4),(c,4),(d,1)\}.\] Since each element \(X\) appears exactly once as a first coordinate, \(f\) is a function with domain \(X\) and codomain \(Y\) (i.e., \(f:X\to Y\)). In this case, we see that \(\range(f)=\{1,2,4\}\). Moreover, we can write things like \(f(a)=2\) and \(c\mapsto 4\), and say things like “\(f\) maps \(b\) to 4" and “the image of \(d\) is 1." The function diagram for \(f\) is depicted in Figure 8.1.

    8.1.jpg
    Figure 8.1: Function diagram for a function from X = {a,b, c, d,} to Y = {1,2,3,4}.

    Problem 8.3. Determine whether each of the relations defined in the following examples and problems is a function.

    1. Example 7.3 (see Figure 7.1)
    2. Example 7.14 (see Figure 7.3)
    3. Problem 7.15
    4. Problem 7.21

    Problem 8.4. Let \(X=\{\circ, \square,\triangle, smiley\}\) and \(Y=\{a,b,c,d,e\}\). For each of the following relations, draw the corresponding digraph and determine whether the relation represents a function from \(X\) to \(Y\), \(Y\) to \(X\), \(X\) to \(X\), or does not represent a function. If the relation is a function, determine the domain, codomain, and range.

    1. \(f=\{(\circ, a),(\square,b),(\triangle,c),(smiley,d)\}\)
    2. \(g=\{(\circ, a),(\square,b),(\triangle,c),(smiley,c)\}\)
    3. \(h=\{(\circ, a),(\square,b),(\triangle,c),(\circ,d)\}\)
    4. \(k=\{(\circ, a),(\square,b),(\triangle,c),(smiley,d),(\square,e)\}\)
    5. \(l=\{(\circ, e),(\square,e),(\triangle,e),(smiley,e)\}\)
    6. \(m=\{(\circ, a),(\triangle,b),(smiley,c)\}\)
    7. \(i=\{(\circ,\circ),(\square, \square),(\triangle,\triangle),(smiley,smiley)\}\)
    8. Define the relation \(\operatorname{happy}\) from \(Y\) to \(X\) via \((y,smiley)\in\operatorname{happy}\) for all \(y\in Y\).
    9. \(\operatorname{nugget}=\{(\circ,\circ),(\square, \square),(\triangle,\triangle),(smiley,\square)\}\)

    The last two parts of the previous problem make it clear that functions may have names consisting of more than one letter. The function names \(\sin\), \(\cos\), \(\log\), and \(\ln\) are instances of this that you have likely encountered in your previous experience in mathematics. One thing that you may have never noticed is the type of font that we use for function names. It is common to italicize generic function names like \(f\) but not common function names like \(\sin\). However, we always italicize the variables used to represent the input and output for a function. For example, consider the font types used in the expressions \(\sin(x)\) and \(\ln(a)\).

    Problem 8.5. What properties does the digraph for a relation from \(X\) to \(Y\) need to have in order for it to represent a function?

    Problem 8.6. In high school you may have been told that a graph represents a function if it passes the vertical line test. Carefully state what the vertical line test says and then explain why it works.

    Sometimes we can define a function using a formula. For example, we can write \(f(x)=x^2-1\) to mean that each \(x\) in the domain of \(f\) maps to \(x^2-1\) in the codomain. However, notice that providing only a formula is ambiguous! A function is determined by its domain, codomain, and the correspondence between these two sets. If we only provide a description for the correspondence, it is not clear what the domain and codomain are. Two functions that are defined by the same formula, but have different domains or codomains are not equal.

    Example 8.7. The function \(f:\mathbb{R}\to \mathbb{R}\) defined via \(f(x)=x^{2}-1\) is not equal to the function \(g:\mathbb{N}\to\mathbb{R}\) defined by \(g(x)=x^{2}-1\) since the two functions do not have the same domain.

    Sometimes we rely on context to interpret the domain and codomain. For example, in a calculus class, when we describe a function in terms of a formula, we are implicitly assuming that the domain is the largest allowable subset of \(\mathbb{R}\)—sometimes called the default domain—that makes sense for the given formula while the codomain is \(\mathbb{R}\).

    Example 8.8. If we write \(f(x)=x^2-1\), \(g(x)=\sqrt{x}\), and \(h(x)=\frac{1}{x}\) without mentioning the domains, we would typically interpret these as the functions \(f:\mathbb{R}\to \mathbb{R}\), \(g:[0,\infty)\to \mathbb{R}\), and \(h:\mathbb{R}\setminus \{0\}\to \mathbb{R}\) that are determined by their respective formulas.

    Problem 8.9. Provide an example of each of the following. You may draw a function diagram, write down a list of ordered pairs, or write a formula as long as the domain and codomain are clear.

    1. A function \(f\) from a set with 4 elements to a set with 3 elements such that \(\range(f)=codom(f)\).
    2. A function \(g\) from a set with 4 elements to a set with 3 elements such that \(\range(g)\) is strictly smaller than \(codom(g)\).

    Problem 8.10. Let \(f:X\to Y\) be a function and suppose that \(X\) and \(Y\) are finite sets with \(n\) and \(m\) elements, respectively, such that \(n<m\). Is it possible for \(\range(f)=codom(f)\)? If so, provide an example. If this is not possible, explain why.

    There are a few special functions that we should know the names of.

    Definition 8.11. If \(X\) and \(Y\) are nonempty sets such that \(X\subseteq Y\), then the function \(\iota:X\to Y\) defined via \(\iota(x)=x\) is called the inclusion map from \(X\) into \(Y\).

    Note that “\(\iota\)" is the Greek letter “iota".

    Problem 8.12. Let \(X=\{a,b,c\}\) and \(Y=\{a,b,c,d\}\). Draw the function diagram of the inclusion map from \(X\) into \(Y\).

    If the domain and codomain are equal, the inclusion map has a special name.

    Definition 8.13. If \(X\) is a nonempty set, then the function \(i_X:X\to X\) defined via \(i_X(x)=x\) is called the identity map (or identity function) on \(X\).

    Example 8.14. The relation defined in Problem 8.4(7) is the identity map on \(X=\{\circ, \square,\triangle,smiley\}\).

    Problem 8.15. Draw a portion of the graph of the identity map on \(\mathbb{R}\) as a subset of \(\mathbb{R}^2\).

    Problem 8.16. Let \(A\) be a nonempty set.

    1. Suppose \(R\) is an equivalence relation on \(A\). What conditions on \(R\) must hold in order for \(R\) to be a function from \(A\) to \(A\)?
    2. Suppose \(f:A\to A\) is a function. Under what conditions is \(f\) an equivalence relation on \(A\)?

    Definition 8.17. Any function \(f:X\to Y\) defined via \(f(x)=c\) for a fixed \(c\in Y\) is called a constant function.

    Example 8.18. The function defined in Problem 8.4(8) is an example of a constant function. Notice that we can succinctly describe this function using the formula \(\operatorname{happy}(y)=smiley\).

    Definition 8.19. A piecewise-defined function (or piecewise function) is a function defined by specifying its output on a partition of the domain.

    Note that “piecewise" is a way of expressing the function, rather than a property of the function itself.

    Example 8.20. We can express the function in Problem 8.4(9) as a piecewise function using the formula \[\operatorname{nugget}(x)=\begin{cases} x, & \mbox{if } x\mbox{ is a geometric shape},\\ \square, & \mbox{otherwise}. \end{cases}\]

    Example 8.21. The function \(f:\mathbb{R}\to \mathbb{R}\) defined via \[f(x)=\begin{cases} x^2-1, & \mbox{if } x\geq 0,\\ 17, & \mbox{if } -2\leq x< 0,\\ -x, & \mbox{if } x<-2 \end{cases}\] is an example of a piecewise-defined function.

    Problem 8.22. Define \(f:\mathbb{R}\setminus\{0\}\to \mathbb{R}\) via \(f(x)=\frac{|x|}{x}\). Express \(f\) as a piecewise function.

    It is important to point out that not every function can be described using a formula! Despite your prior experience, functions that can be represented succinctly using a formula are rare.

    The next problem illustrates that some care must be taken when attempting to define a function.

    Problem 8.23. For each of the following, explain why the given description does not define a function.

    1. Define \(f:\{1,2,3\}\to \{1,2,3\}\) via \(f(a)=a-1\).
    2. Define \(g:\mathbb{N}\to \mathbb{Q}\) via \(g(n)=\frac{n}{n-1}\).
    3. Let \(A_1=\{1,2,3\}\) and \(A_2=\{3,4,5\}\). Define \(h:A_1\cup A_2\to \{1,2\}\) via \[h(x)=\begin{cases} 1, & \mbox{if }x\in A_1\\ 2, & \mbox{if }x\in A_2. \end{cases}\]
    4. Define \(s:\mathbb{Q}\to \mathbb{Z}\) via \(s(a/b)=a+b\).

    In mathematics, we say that an expression is well defined (or unambiguous) if its definition yields a unique interpretation. Otherwise, we say that the expression is not well defined (or is ambiguous). For example, if \(a,b,c\in\mathbb{R}\), then the expression \(abc\) is well defined since it does not matter if we interpret this as \((ab)c\) or \(a(bc)\) since the real numbers are associative under multiplication. This issue was lurking behind the scenes in the statement of Theorem 7.94. In particular, the expressions \[[a_1]_n+[a_2]_n+\cdots+ [a_k]_n\] and \[[a_1]_n [a_2]_n \cdots [a_k]_n\] are well defined in \(\mathbb{Z}/n\mathbb{Z}\) in light of Theorems 7.92(2) and 7.93(2).

    When we attempt to define a function, it may not be clear without doing some work that our definition really does yield a function. If there is some potential ambiguity in the definition of a function that ends up not causing any issues, we say that the function is well defined. However, this phrase is a bit of misnomer since all functions are well defined. The issue of whether a description for a proposed function is well defined often arises when defining things in terms of representatives of equivalence classes, or more generally in terms of how an element of the domain is written. For example, the descriptions given in Parts (c) and (d) of Problem 8.23 are not well defined. To show that a potentially ambiguous description for a function \(f:X\to Y\) is well defined prove that if \(a\) and \(b\) are two representations for the same element in \(X\), then \(f(a)=f(b)\).

    Problem 8.24. For each of the following, determine whether the description determines a well-defined function.

    1. Define \(f:\mathbb{Z}/5\mathbb{Z}\to \mathbb{N}\) via \[f([a]_5)=\begin{cases} 0, & \mbox{if } a\mbox{ is even}\\ 1, & \mbox{if } a\mbox{ is odd}. \end{cases}\]
    2. Define \(g:\mathbb{Z}/6\mathbb{Z}\to \mathbb{N}\) via \[g([a]_6)=\begin{cases} 0, & \mbox{if } a\mbox{ is even}\\ 1, & \mbox{if } a\mbox{ is odd}. \end{cases}\]
    3. Define \(m:\mathbb{Z}/8\mathbb{Z}\to \mathbb{Z}/10\mathbb{Z}\) via \(m([x]_{8})=[6x]_{10}\).
    4. Define \(h:\mathbb{Z}/10\mathbb{Z}\to \mathbb{Z}/10\mathbb{Z}\) via \(h([x]_{10})=[6x]_{10}\).
    5. Define \(k:\mathbb{Z}/43\mathbb{Z}\to \mathbb{Z}/43\mathbb{Z}\) via \(k([x]_{43})=[11x-5]_{43}\).
    6. Define \(\ell:\mathbb{Z}/15\mathbb{Z}\to \mathbb{Z}/15\mathbb{Z}\) via \(\ell([x]_{15})=[5x-11]_{15}\).

    Problem 8.25. Let \(k,n\in\mathbb{N}\) and \(m\in\mathbb{Z}\). Under what conditions will \(f_m: \mathbb{Z}/n\mathbb{Z}\to \mathbb{Z}/k\mathbb{Z}\) given by \(f_m([x]_n) = [mx]_k\) be a well-defined function? Prove your claim.


    This page titled 8.1: Introduction to Functions is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Dana Ernst via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?