Skip to main content
Mathematics LibreTexts

2.1: Relations and functions

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

    Learning Objectives
    • Interpret relations through ordered pairs, mapping diagrams, and tables
    • Determine the domain and range of a relation
    • Determine if a relation is a function
    • Use function notation to evaluate a function defined with ordered pairs and an equation
    • Determine the domain and range of a function

    Relations and Functions

    One of the most important ideas in mathematics is the ability to notice and describe relationships. In this section, we discuss how math can be used to define relationships between different numbers using what are called relations and functions.

    Relations

    We often indicate that two numbers are related to each other using notation that we call an ordered pair. This notation pairs two numbers together using parentheses, for example, \((3, 7)\). You can interpret this as "3 is related to 7". The order is important because the first number is often thought as an input and the second number is often thought as an output. If we want to indicate a generic ordered pair, it is common to write it as \(x, y\), where \(x\) is used to indicate inputs and \(y\) is used to indicate outputs.

    Ordered pairs are the building blocks of a relation, which we can use to describe how numbers might be related to each other.

    Definition: RELATION

    A collection of ordered pairs is called a relation.

    For example, the collection of ordered pairs \[R=\{(0,1),(0,2),(3,4)\}\] is a relation. We can interpret this as "0 is related to 1", "0 is also related to 2", and "3 is related to 4".

    While ordered pairs offer a concise way to show relations, we can also use mapping diagrams with arrows or tables to display relations, with the first entry (or input) of each ordered pair on the left side of the diagram or table and the second entry (or output) on the right side of the diagram or table.

    Example \(\PageIndex{1}\)

    Create a mapping diagram and a table for the relation \(R=\{(0,1),(0,2),(3,4)\}\).

    Solution

    A mapping diagram connects the related numbers using arrows, with the first entry (or input) on the left side and the second entry (or output) on the right side.

    WeChatec9244409a735f5233185bfb80001b95.png

    The pair \((0,1)\) means "0 is related to 1", so we draw an arrow from 0 pointing to 1, and the pair \((0, 2)\) means "0 is related to 2", so we also draw an arrow from 0 pointing to 2. Similarly, \(3, 4\) means that "3 is related to 4", so our last arrow starts at 3 and points to 4.

    If we want to set this up in a table, we place our inputs on the left side and our outputs on the right side:

    \(\begin{array} {|c|c|}\hline \text{Inputs (or \(x\))} & \text{Outputs (or \(y\))} \\ \hline 0 & 1 \\ \hline 0 & 2 \\ \hline 3 & 4 \\ \hline \end{array}\)

    Since the order of the numbers in each pair matters, it's helpful to be able to talk about just the inputs or just the outputs for a specific relation. These are what we call the domain and range of a relation.

    Definition: DOMAIN

    The domain of a relation is the collection of the first entries of each ordered pair.

    It is helpful to think of the domain as the collection of all inputs or \(x\) values.

    Example \(\PageIndex{2}\)

    Find the domain for the relation \(R = \{(0, 1), (0, 2), (3, 4)\}\).

    Solution

    The domain is the collection of the first entries of the ordered pairs in a relation. For \(R\), this is the collection \(\text { Domain }=\{0, 3\}\). Note that even though 0 appears twice as an input, we only list it once.

    When we want to talk about the collection of outputs, or the second entry of each ordered pair in a relation, we call this the range of the relation.

    Definition: RANGE

    The range of a relation is the collection the second entry of each ordered pair.

    We often talk about the range as being the collection of all possible outputs or \(y\) values.

    Example \(\PageIndex{3}\)

    Find the range for the relation \(R = \{(0, 1), (0, 2), (3, 4)\}\).

    Solution

    The range is the collection of the second entries of the ordered pairs in a relation. For \(R\), this is the collection

    \[\text { Range }=\{1, 2, 4\}.\]

    Try finding both the range and domain for a relation!

    Exercise \(\PageIndex{4}\)

    Find the domain and range for the relation \(R = \{(-3, 5), (-2, 3), (0, 12), (1, -2), (6, 5)\}\)

    Answer

    The domain is \(\{-3, -2, 0, 1, 6\}\). The range is \(\{-2, 3, 5, 12\}\).

    Exercise \(\PageIndex{5}\)

    Find the domain and range for the relation \(R = \{(-4, 2), (-4, 5), (-1, 0), (3, -2), (5, -1)\}\).

    Answer

    The domain is \(\{-4, -1, 3, 5\}\). The range is \(\{-2, -1, 0, 2, 5\}\).

    We can also determine the domain and range of a relation that has been displayed using a mapping diagram or a table.

    Example \(\PageIndex{6}\)

    Determine the domain and range for the relation shown in the mapping diagram.

    dr_map_ex2.JPG

    Solution

    The domain is \(\{-2, -1, 0, 2\}\). Notice that we do not include 1 in the domain because it is not mapped to anything in the relation, so it is not an input.

    The range is \(\{-5, -4, -3, -2\}\). Notice that we do not include -1 in the range because it does not have anything that gets mapped to it by the relation, so it is not an output.

    Exercise \(\PageIndex{7}\)

    Determine the domain and range for the relation shown in the mapping diagram.

    dr_map_ex1.JPG

    Answer

    The domain is \(\{-3, -1, 0, 4, 5\}\). The range is \(\{-2, 0, 1, 2, 7\}\).

    Let's try similar examples for a relation defined using a table.

    Example \(\PageIndex{8}\)

    Determine the domain and range for the relation shown in the table.

    \(\begin{array} {|c|c|}\hline \text{Inputs (or \(x\))} & \text{Outputs (or \(y\))} \\ \hline -2 & 0 \\ \hline -1 & 2 \\ \hline 3 & -2 \\ \hline 3 & 4 \\ 5 & 4 \\ \hline \end{array}\)

    Solution

    The domain is \(\{-2, -1, 3, 5\}\). The range is \(\{-2, 0, 2, 4\}\).

    Exercise \(\PageIndex{9}\)

    Determine the domain and range for the relation shown in the table.

    \(\begin{array} {|c|c|}\hline \text{Inputs (or \(x\))} & \text{Outputs (or \(y\))} \\ \hline -17 & -3 \\ \hline -5 & 4 \\ \hline 0 & -1 \\ \hline 7 & 8 \\ 10 & 4 \\ \hline \end{array}\)

    Answer

    The domain is \(\{-17, -5, 0, 7, 10\}\). The range is \(\{-3, -1, 4, 8\}\).

    Functions

    A function is a special type of relation and will be very important throughout the rest of the course.

    Definition: FUNCTION

    A function is a relation where each input has exactly one output.

    In other words, a function is a specific kind of relation where none of the first entries are repeated. If we want to think about this in terms of domain and range, each number in the domain is related to exactly one number in the range.

    Example \(\PageIndex{10}\)

    Determine if the following relations are functions.

    1. \(R = \{(0, 1), (1, 3), (3, 4), (5, 2)\}\)
    2. \(R = \{(0, 1), (0, 2), (3, 4)\}\)
    Solution
    1. For the relation \(R = \{(0, 1), (1, 3), (3, 4), (5, 2)\}\), each input has exactly one output, so it is a function.
    2. For the relation \(R = \{(0, 1), (0, 2), (3, 4)\}\), the input 0 has two outputs, 1 and 2, that correspond to it, so this is not a function (but it is still a relation!).
    Exercise \(\PageIndex{11}\)

    Determine if the following relations are functions.

    1. \(R = \{(-3, 2), (1, 3), (4, 4), (1, -2), (0, -4)\}\)
    2. \(R = \{(-5, -3), (1, 1), (6, 2), (7, 2)\}\)
    Answer
    1. Not a function
    2. Function

    A mapping diagram can make it easier to determine if a relation is also a function. When a relation is a function, each input has exactly one output, so on its mapping diagram, each input will only have one arrow leaving it. When a relation is not a function, some of the inputs may have more than one output, so some inputs may have multiple arrows leaving it.

    Example \(\PageIndex{12}\)

    Use a mapping diagram to determine if the relation \(R = \{(0, 1), (1, 3), (3, 4), (5, 2)\}\) is a function.

    Solution

    First, create the mapping diagram corresponding to this relation. You can choose whether or not to include the numbers not used in the ordered pairs; a few extra numbers isn't a big deal and won't affect the answer.

    funct_map_ex1.JPG

    Since each input on the left only has one arrow attached to it, each input has only one output, meaning \(R\) is a function. (it's okay that not every number is an input or an output!)

    Example \(\PageIndex{13}\)

    Use a mapping diagram to determine if the relation \(R = \{(0, 1), (0, 2), (3, 4)\}\) is a function.

    Solution

    First, we create the mapping diagram for this relation.

    WeChatec9244409a735f5233185bfb80001b95.png

    Since 0 has two arrows leaving it, we see that it has two outputs that correspond to it. Therefore, \(R\) cannot be a function.

    Function Notation

    One way to think about a function is as being a rule that pairs one input with one output. The rule can take many forms. For example, we can use sets of ordered pairs, graphs, and mapping diagrams to describe the function. In the sections that follow, we will explore other ways of describing a function, for example, through the use of equations and simple word descriptions.

    Before we can talk about writing the rule for a function using an equation, we must define a new notation that we call function notation. If \(f\) is a function, function notation looks like \[f(input) = output.\] Or if we want to use \(x\)'s and \(y\)'s, it is common to say \[f(x) = y.\]

    In other words, if we want to know what a function does to a given input, we indicate the function with \(f\), place the \(input\) in parentheses, and set it equal to the corresponding output. We call this evaluating the function. Note: in this setting, the parentheses do not represent multiplication; we are not multiplying the function \(f\) by the input.

    Example \(\PageIndex{14}\)

    Using the function \(f = \{(0, 1), (1, 3), (3, 4), (5, 2)\}\), evaluate the following:

    1. f(1)
    2. f(5)
    3. f(3)
    Solution
    1. Since the function \(f\) sends 1 to 3, \(f(1) = 3\).
    2. Since the function \(f\) sends 5 to 2, \(f(5) = 2\).
    3. Since the function \(f\) sends 3 to 4, \(f(3) = 4\).

    In \(a.\), for example, this notation is read as "\(f\) of 1 is equal to 3", meaning that when we evaluate \(f\) with the input 1, the output is 3.

    It is helpful to think of a function as a machine. The machine receives input, processes it according to some rule, then outputs a result. Something goes in (input), then something comes out (output). This is how a function pairs numbers in its domain with numbers in its range.

    For the rest of this course, the rule that a function follows will be given by an equation using a variable. This allows us to evaluate a function for a much larger collection of numbers than in our previous examples. For example, \[f(x) = 2x.\] For this function, the rule is that we take the input number that \(x\) represents, and then multiply it by 2.

    To evaluate a function \(f\) that uses an equation for a rule, we take the input and swap it out for \(x\) in the rule.

    Example \(\PageIndex{15}\)

    For the function \(f(x) = 2x\), evaluate the following:

    1. \(f(3)\)
    2. \(f(-1)\)
    3. \(f(0)\)
    Solution
    1. To evaluate \(f(3)\), we substitute the \(x\) in the rule that \(f\) follows with the 3. Therefore, \(f(3) = 2\cdot 3 = 6.\) So our final answer is \(f(3) = 6\).
    2. To evaluate \(f(-1)\), we substitute the \(x\) in the rule that \(f\) follows with the -1. Therefore, \(f(-1) = 2\cdot (-1) = -2.\) So our final answer is \(f(-1) = -2\).
    3. To evaluate \(f(0)\), we substitute the \(x\) in the rule that \(f\) follows with the 0. Therefore, \(f(0) = 2\cdot 0 = 0.\) So our final answer is \(f(0) = 0\).
    Exercise \(\PageIndex{16}\)

    For the function \(f(x) = x^2 + 3\), evaluate the following:

    1. \(f(-2)\)
    2. \(f(0)\)
    3. \(f(4)\)
    Answer
    1. To evaluate \(f(-2)\), we substitute the \(x\) in the rule that \(f\) follows with the -2. Be careful with the negative! We recommend surrounding the -2 with parentheses. We get \(f(-2) = (-2)^2 + 3 = 4 + 3 = 7.\). So our final answer is \(f(-2) = 7\).
    2. \(f(0) = 3\).
    3. \(f(4) = 19\).
    Exercise \(\PageIndex{17}\)

    For the function \(f(x) = |x - 4| + 1\), evaluate the following:

    1. \(f(-5)\)
    2. \(f(-1)\)
    3. \(f(0)\)
    Answer
    1. \(f(-5) = 10\)
    2. \(f(-1) = 6\)
    3. \(f(0) = 5\)

    Extracting the Domain of a Function Using an Equation

    We’ve seen that the domain of a relation or function is the set of all the first coordinates of its ordered pairs. However, if a functional relationship is defined by an equation such as \(f(x) = 3x − 4\), then it is not practical to list all ordered pairs defined by this relationship. For any real x-value, you get an ordered pair. For example, if x = 5, then \(f(5) = 3(5) − 4 = 11\), leading to the ordered pair (5, f(5)) or (5, 11). As you can see, the number of such ordered pairs is infinite. For each new x-value, we get another function value and another ordered pair.

    Therefore, it is easier to turn our attention to the values of x that yield real number responses in the equation \(f(x) = 3x − 4\). This leads to the following key idea.

    Definition: DOMAIN OF A FUNCTION

    If a function is defined by an equation, then the domain of the function is the set of “permissible x-values,” the values that produce a real number response defined by the equation.

    We sometimes like to say that the domain of a function is the set of “all possible inputs.”

    Example \(\PageIndex{18}\)

    Find the domain for the following function: \(f(x) = 3x − 4\)

    Solution

    it is immediately apparent that we can use any value we want for \(x\) in the rule \(f(x) = 3x − 4\). Thus, the domain of \(f\) is all real numbers. We can write that the domain \(D=\mathbb{R}\), or we can use interval notation and write that the domain \(D=(-\infty, \infty)\).

    However, not every input is allowed when defining a function using an equation for the rule. For example, you cannot take the square root of a negative number and get a real number back, or divide by zero. So let's look at examples that have restrictions to their domain.

    Example \(\PageIndex{19}\)

    Find the domain for the following function: \(f(x) = \sqrt{x}\)

    Solution

    It is not possible to take the square root of a negative number. Therefore, \(x\) must either be zero or a positive real number. In set-builder notation, we can describe the domain with \(D=\{x : x \geq 0\}\). In interval notation, we write \(D=[0, \infty)\).

    Example \(\PageIndex{20}\)

    Find the domain for the following function: \(f(x)=1 /(x-3)\)

    Solution

    If we define a function with this rule we immediately see that \(x = 3\) will put a zero in the denominator. Division by zero is not allowed. Therefore, 3 is not in the domain of \(f\). No other \(x\)-value will cause a problem. The domain of \(f\) is best described with set-builder notation as \(D=\{x : x \neq 3\}\); that is, any number other than 3 is allowed to be "plugged in" the function \(f(x)=x1/(x-3)\).

    Extracting the Range of a Function Using an Equation

    We’ve also seen that the range of a relation or function is the set of all the second coordinates of its ordered pairs. Once again, if a function is defined using an equation such as \(f(x) = 3x − 4\), then we cannot list all the possible outputs.

    So in the case of finding the range of a function based on an equation, we want to describe all the possible outputs created.

    Definition: RANGE OF A FUNCTION

    If a function is defined by an equation, then the range of the function is the set of “possible outputs,” the values that can be created by plugging in different \(x\) values.

    It's helpful to think of the range of a function as “all possible outputs.”

    Example \(\PageIndex{21}\)

    Find the range for the following function: \(f(x) = 3x − 4\)

    Solution

    We can create any real number using the rule \(3x - 4\). Therefore, the range of \(f\) is all real numbers. We say that the range is \(R=\mathbb{R}\), or we can use interval notation and say that the range is \(R=(-\infty, \infty)\).

    Just like with the domain, not every function has a range including all real numbers. That is, not every function is capable of producing all real numbers.

    Example \(\PageIndex{22}\)

    Find the range for the following function: \(f(x) = x^2\)

    Solution

    If we square any real number, it becomes positive. For example, \(f(-2) = 4\) or \(f(-5) = -25\). If we square zero, we just get zero back. In other words, \(f(0) = 0\). Squared numbers can be as large as we want them to be, so the range has to include zero and any positive number, but it cannot include any negative numbers. So we can describe the range with \(R=[0, \infty)\).

    Example \(\PageIndex{23}\)

    Find the range for the following function: \(f(x)=1 /(x-3)\)

    Solution

    No matter what value we place in the denominator, the rule \(1/(x - 3)\) will never produce the number 0. However, it is possible to create any other real number using this rule. Therefore, the range of this function is everything except 0. We indicate this by saying that the range is \(R = \{y: y\neq 0\}\). In other words, this function can produce any \(y\)-value except 0.

    Key Concepts

    • An ordered pair relates one number to another number. The first number is often represented with an \(x\) and the second with a \(y\). Order is important! These numbers cannot be swapped and still have the same meaning.
    • A relation is a collection of ordered pairs
      • A relation can also be visualized using a table or mapping diagram
    • The domain of a relation is the collection of the first entries of each ordered pair. The range of a relation is the collection of the second entries of each ordered pair.
    • A function is a relation where each input has exactly one output.
    • Function notation looks like \(f(input) = output\) or \(f(x) = y\). We use this notation to define the rule of the function through an equation based on \(x\).
    • When we substitute a value into the rule for \(f(x)\) to determine the corresponding output, we call this evaluating the function.
    • The domain of a function is the collection of all possible inputs. The range of a function is the collection of all possible outputs.

    This page titled 2.1: Relations and functions is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Stanislav A. Trunov and Elizabeth J. Hale.

    • Was this article helpful?