Skip to main content
\(\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}}\)
Mathematics LibreTexts

5.1: Intro to Relations and Functions

  • Page ID
    25157
  • \( \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}}\)

    Relations

    Given two nonempty sets \(A\) and \(B\), we are often interested in some sort of relationship between the elements from these two sets. A familiar example is the equality of two numbers. By saying \(a=b\), we are proclaiming that the two numbers \(a\) and \(b\) are related by being equal in value. Likewise, \(a\geq b\) is another example of a relation.

    Example \(\PageIndex{1}\label{eg:defnrelat-01}\)

    Given \(a, b\in\mathbb{R}^*\), declare \(a\) and \(b\) to be related if they have the same sign. For instance, \(7.14\) and \(e\) are related, so are \(-\pi\) and \(-\sqrt{2}\). However, 5 and \(-2\) are not. Note that \(a\) is related to \(b\) implies that \(b\) is also related to \(a\).

    Example \(\PageIndex{2}\label{eg:defnrelat-02}\)

    For \(a,b\in\mathbb{R}\), define “\(a\) is related to \(b\)” if and only if \(a<b\). Take note that \(3<5\), but \(5\nless3\). This demonstrates that \(a\) is related to \(b\) does not necessarily imply that \(b\) is also related to \(a\).

    Example \(\PageIndex{3}\label{eg:defnrelat-03}\)

    Let \(A\) be a set of students, and let \(B\) be a set of courses. Given \(a\in A\) and \(b\in B\), define “\(a\) is related to \(b\)” if and only if student \(a\) is taking course \(b\). While it could be possible that “John Smith is related to MATH 210” because John is taking MATH 210, it is certainly absurd to say that “MATH 210 is related to John Smith,” because it does not make much sense to say that MATH 210 is taking John Smith. This again illustrates that \(a\) is related to \(b\) does not necessarily imply that \(b\) is also related to \(a\).

    In these examples, we see that when we say “\(a\) is related to \(b\),” the order in which \(a\) and \(b\) appear may make a difference. This suggests the following definition.

    Definition

    A relation from a set \(A\) to a set \(B\) is a subset of \(A \times B\). Hence, a relation \(R\) consists of ordered pairs \((a,b)\), where \(a\in A\) and \(b\in B\). If \((a,b)\in R\), we say that is related to , and we also write \(a\,R\,b\).

    Remark

    We can also replace \(R\) by a symbol, especially when one is readily available. This is exactly what we do in, for example, \(a<b\). To say it is not true that \(a<b\), we can write \(a\nless b\). Likewise, if \((a,b)\notin R\), then \(a\) is not related to \(b\), and we could write \(a\!\not\!R\,b\). 

    Since a relation is a set, we can describe a relation by listing its elements (that is, using the roster method).

    Example \(\PageIndex{4}\label{eg:parity}\)

    Let \(A=\{1,2,3,4,5,6\}\) and \(B=\{1,2,3,4\}\). Define \((a,b)\in R\) if and only if \((a-b)\bmod 2 = 0\). Then \[R=\{(1,1), (1,3), (2,2), (2,4), (3,1), (3,3), (4,2), (4,4), (5,1), (5,3), (6,2), (6,4)\}.\] We note that \(R\) consists of ordered pairs \((a,b)\) where \(a\) and \(b\) have the same parity. Be cautious, that \(1\leq a\leq 6\) and \(1\leq b\leq 4\). Hence, it is meaningless to talk about whether \((1,5)\in R\) or \((1,5)\notin R\).

    hands-on Exercise \(\PageIndex{1}\label{he:relat-div}\)

    Let \(A=\{2,3,4,7\}\) and \(B=\{1,2,3,\ldots,12\}\). Define \(a\,S\,b\) if and only if \(a\mid b\). Use the roster method to describe \(S\).

    In the last example, 7 never appears as the first element (in the first coordinate) of any ordered pair. Likewise, 1, 5, 7, and 11 never appear as the second element (in the second coordinate) of any ordered pair.

    Functions

    The functions we studied in calculus are real functions, which are defined over a set of real numbers, and the results they produce are also real. In this chapter, we shall study their generalization over other sets. The definition could be difficult to grasp at the beginning, so we would start with a brief introduction.

    Most students view real functions as computational devices. However, in the generalization, functions are not restricted to computation only. A better way to look at functions is their input-output relationship. Let \(f\) denote a function. Given an element (which need not be a number), we call the result from \(f\) the image under f, and write \(f(x)\), which is read as “\(f\) of \(x\).”

    Imagine \(f\) as a machine. It takes the input value \(x\), and returns \(f(x)\) as the output value. This input-output relationship is depicted in Figure 6.1 in two different ways.

    clipboard_efd9b65e0b8b2e65b47825ae23962c3c8.png

    The question is: how could we obtain \(f(x)\)? A function need not involve any computation. Consequently, we cannot speak of “computing” the value of \(f(x)\). Instead, we talk about what is the rule we follow to obtain \(f(x)\). This rule can be described in many forms. We can, of course, use a computational rule. But a table, an algorithm, or even a verbal description also work as well.

    Domain & Codomain

    When we say a real function is defined over the real numbers, we mean the input values must be real numbers. The output values are also real numbers. In general, the input and output values need not be of the same type. The nearest integer function, denoted \([x]\), rounds the real number \(x\) to the nearest integer. Here, the images (the output values) are integers. Consequently, we need to distinguish the set of input values from the set of possible output values. We call them the domain and the codomain, respectively, of the function.

    Example \(\PageIndex{5}\label{eg:fcintro-1}\)

    When a professor reports the final letter grades for the students in her class, we can regard this as a function \(g\). The domain is the set of students in her class, and the codomain could be the set of letter grades \(\{A, B, C, D, F\}\).

    Range & ONTO

    We said the codomain is the set of possible output values, because not every element in the codomain needs to appear as the image of some element from the domain. If no student fails the professor’s class in Example 5.1.5, no one will receive the final grade F. The collection of the images (the final letter grades) form a subset of the codomain. We call this subset the range of the function \(g\). The range of a function can be a proper subset of the codomain. Hence, the codomain of a function is different from the set of its images. If the range of a function does equal to the codomain, we say that the function is onto.

    Definition: Range

    The set of all images of a function is called the range.

    Note: the range will be a subset of the codomain.

    Example \(\PageIndex{6}\label{eg:fcintro-2}\)

    For the nearest integer function \(h(x)=[x]\), the domain is \(\mathbb{R}\). The codomain is \(\mathbb{Z}\), and the range is also \(\mathbb{Z}\). Hence, the nearest integer function is onto.

    Example \(\PageIndex{7}\)

    Let \(x\) be a real number. The greatest integer function \(\lfloor x\rfloor\) returns the greatest integer less than or equal to \(x\). For example, \[\big\lfloor \sqrt{50}\,\big\rfloor = 7, \qquad \lfloor -6.34 \rfloor = -7, \qquad\mbox{and}\qquad \lfloor 15 \rfloor = 15.\] Therefore, \(\lfloor x\rfloor\) returns \(x\) if it is an integer, otherwise, it rounds \(x\) down to the next closest integer. Hence, it is also called the floor function of \(x\). It is clear that its domain is \(\mathbb{R}\), and the codomain and range are both \(\mathbb{Z}\).

    hands-on exercise \(\PageIndex{2}\)

    Let \(x\) be a real number. The least integer function \(\lceil x\rceil\) returns the least integer greater than or equal to \(x\). For example, \[\big\lceil \sqrt{50}\,\big\rceil = 8, \qquad \lceil -6.34 \rceil = -6, \qquad\mbox{and}\qquad \lceil 15 \rceil = 15.\] Thus, \(\lceil x\rceil\) returns \(x\) if it is an integer, otherwise, it rounds \(x\) up to the next closest integer. Hence, it is also called the ceiling function of \(x\). What is its domain and codomain?

    We impose two restrictions on the input-output relationships that we call functions. For any fixed input value \(x\), the output from a function must be the same every time we use the function. As a machine, it spits out the same answer every time we feed the same value \(x\) to it. As a calculator, it displays the same answer on its screen every time we enter the same value \(x\), and push the button for the function. We call the output value the image of \(x\), and write \(f(x)\). The first important requirement for a function \(f\) is: the image \(f(x)\) is unique for any fixed \(x\)-value.

    A good machine must perform properly. In terms of a function \(f\), we must be able to obtain \(f(x)\) for any value \(x\) (and, of course, produce only one result for each \(x\)). This is perhaps a little bit too demanding. A remedy is to restrict our attention to those \(x\)’s over which \(f\) would work. The set of legitimate input values is precisely what we call the domain of the function. Consequently, the second requirement says: for every element \(x\) from the domain, the output value \(f(x)\) should be well-defined. This is the mathematical way of saying that the value \(f(x)\) can be obtained, or the value \(f(x)\) exists.

    Example \(\PageIndex{8}\)

    Compare this to a calculator. If you enter a negative number and press the \(\sqrt{\phantom{x}}\,\) button, an error message will appear. To be able to compute the square root of a number, the number must be nonnegative. The domain of a function is the set of acceptable input values for which meaningful results can be found. For the square root function, the domain is \(\mathbb{R}^+\cup\{0\}\), which is the set of nonnegative real numbers.

    hands-on exercise \(\PageIndex{3}\)

    For the square root function, we may regard its codomain as \(\mathbb{R}\). What is its range? Is the function onto?

    hands-on exercise \(\PageIndex{4}\)

    For the square root function, can we say its domain is \(\mathbb{R}^+\cup0\)? Explain.

    The two conditions or requirements for a relation to be a function:

    • every element in the domain has an image under \(f\), and
    • the image is unique.

    In the next section, we shall present the complete formal definition.

    Summary and Review

    • Relations are generalizations of functions. A relation merely states that the elements from two sets \(A\) and \(B\) are related in a certain way.
    • More formally, a relation is defined as a subset of \(A\times B\).  The domain is the set of elements in \(A\) and the codomain is the set of elements in \(B.\)
    • The range of a relation is the set of elements in \(B\) that appear in the second coordinates of some ordered pairs.
    • For brevity and for clarity, we often write \(x\,R\,y\) if \((x,y)\in R\).
    • Under this convention, the mathematical notations \(\leq\), \(\geq\), \(=\), \(\subseteq\), and their like, can be regarded as relational operators.
    • A function is a rule that assigns to every element in the domain a unique image in the codomain.

    Exercises 

    Exercise \(\PageIndex{1}\)

    Determine the arrow diagram that represents the relation \(R\) defined on \(\{x\in\mathbb{Z} \mid -3\leq x\leq3\}\) by \[x\,R\,y \Leftrightarrow 3\mid(x-y).\]

    Exercise \(\PageIndex{2}\)

    Determine the arrow diagram that represents the relation \(S\) defined on \(\{1,2,4,5,10,20\}\) by \[x\,S\,y \Leftrightarrow \mbox{($x<y$ and $x$ divides $y$)}.\]

    Exercise \(\PageIndex{3}\)

    Let \(D=\{1,2,3,\ldots,30\}\) be the set of dates in November, and let \(W=\{\)Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday\(\}\) be the set of days of the week. For November of this year, define the relation \(T\) from \(D\) to \(W\) by \[(x,y)\in T \Leftrightarrow \mbox{$x$ falls on $y$}.\] List the ordered pairs in \(T\). Is \(T\) a function from \(T\) to \(W\)?

    Exercise \(\PageIndex{4}\)

    Let \(\mathbb{R}\) be the domain and the codomain of the cube root function.  Is it onto?

    Exercise \(\PageIndex{5}\)

    For the square root function, how would you use the interval notation to describe the domain?

    Answer

    \([0,\infty)\)

    Exercise \(\PageIndex{6}\)

    Let \(\mathbb{R}\) be the domain and the codomain of the absolute value function? Is it onto?

    Exercise \(\PageIndex{7}\)

    Is the greatest integer function (or floor) from \(\mathbb{R}\) to \(\mathbb{Z}\) onto? Explain.

    Answer

    Yes, every integer will be the image of some real number input.
    More specifically, let y be any integer. \(\lfloor y\rfloor=y\), so for each \(y\in \mathbb{Z}, \exists x\in \mathbb{R} \mbox{ (namely choose }x=y)(\lfloor x\rfloor=y)\). 

    Exercise \(\PageIndex{8}\)

    (a) \(f:\mathbb{Z} \rightarrow \mathbb{Z}\) by the rule \(f(x)=3x.\)  Is \(f\) onto? Explain completely.

    (b) \(g:\mathbb{Z} \rightarrow \mathbb{Z}\) by the rule \(g(x)=x^3.\)  Is \(g\) onto? Explain completely

    Exercise \(\PageIndex{9}\)

    (a) \(h:\mathbb{R} \rightarrow \mathbb{R}\) by the rule \(h(x)=3x.\)  Is \(h\) onto? Explain completely.

    (b) \(k:\mathbb{R} \rightarrow \mathbb{R}\) by the rule \(k(x)=x^2.\)  Is \(k\) onto? Explain completely

    Answer

    (a) Yes.  Let \(y\) be any real number.  Choose \(x=\frac{1}{3}y\).  \(x \in \mathbb{R}\) since the real numbers are closed under multiplication. Now, \(h(x)=h(\frac{1}{3}y)=3(\frac{1}{3}y)=y.\)  Thus every real number has a pre-image, and therefore \(h\) is onto.
    (b) No.  Consider \(y=-25.\)  If \(y\) has a pre-image under \(k\) then there exists a real number, \(x\) such that \(x^2=-25.\)  Then \(x=\sqrt{-25}\); however, \(\sqrt{-25}\) is not a real number, hence  \(y=-25\) does not have a pre-image under \(k\) in the real numbers.

     

    • Was this article helpful?