##### Tools

This site is devoted to mathematics and its applications. Created and run by Peter Saveliev.

# Operations on functions

## 1 Operations with sets

Let's go back to our the example of five boys that form a set and another set is the set of these four balls:

They are just lists without repetitions: $$\begin{array}{lll} X&=\{\text{ Tom }, \text{ Ken }, \text{ Sid }, \text{ Ned }, \text{ Ben }\},\\ Y&=\{\text{ basketball }, \text{ tennis }, \text{ baseball }, \text{ football }\}. \end{array}$$ We can form a new set that contains all the elements of the two sets.

We merge the two sets together and, once the separator is gone, move the elements around.

Definition. The union of any two sets $X$ and $Y$ is the set that consists of the elements that belong to either $X$ or $Y$. It is denoted by $X\cup Y$.

The most common case is when both sets are subsets of the same set. The unions of these will be subsets of the union of $X$ and $Y$: $$\begin{array}{lll} T=\{\text{ Tom }\},\quad A=\{\text{ Tom, Ken }\},\quad Q=\{\text{ Tom, Ken, Sid }\},\quad ...&\subset X;\\ B=\{\text{ basketball }\},\quad V=\{\text{ basketball, tennis }\},\quad U=\{\text{ basketball, tennis, baseball }\},\quad ...&\subset Y;\\ \Longrightarrow\\ \{\text{ Tom }\}\cup \{\text{ basketball }\}=\{\text{ Tom, basketball }\}&\subset X\cup Y;\\ \{\text{ Tom, Ken }\}\cup \{\text{ basketball, tennis }\}=\{\text{ Tom, Ken, basketball, tennis }\}&\subset X\cup Y.\\ \end{array}$$ So, to find the union of two such sets, we just merge the lists. To find unions of subsets of $X\cup Y$, we merge the lists removing repetitions, i.e., the “overlap” of the two sets: $$\begin{array}{lll} \{\text{ tennis, Tom, Ken }\}\cup \{\text{ basketball, tennis, Tom }\}&=\{\text{ tennis, Tom, Ken, basketball, tennis, Tom }\}\\ &=\{\text{Tom, Ken, basketball, tennis }\}. \end{array}$$

Exercise. Present the unions of all pairs of sets shown above. Now, the triples, and so on.

Example (lists). We merge lists together and then carefully remove the repetitions: $$\{1,2,3,4\}\cup\{3,4,5,6,7\}=\{1,2,3,4,\quad 3,4,5,6,7\}=\{1,2,3,4,5,6,7\}.$$ $\square$

Next, the “overlap” itself. We look at what the two sets have in common:

We find the repeated parts and make them overlap; the rest is thrown out.

Definition. The intersection of any two sets $X$ and $Y$ is the set that consists of all the elements that belong to both $X$ and $Y$. It is denoted by $X\cap Y$.

Here is an example of such computation: $$\begin{array}{lll} \{\text{ tennis, Tom, Ken }\}\cap \{\text{ basketball, tennis, Tom }\}&=\{\text{ tennis, Tom }\}. \end{array}$$

Recall that the set-building notation is used to create a set by stating a condition these numbers are supposed to satisfy: $$Z=\{x:\ \text{ condition for } x\ \}.$$ We consider what happens to sets given this way under these two operations.

Example (equations). Numerical sets are subsets of the real line ${\bf R}$ and some of them came from solving these equations, as their solution sets: $$\begin{array}{l|ll} \text{equation }& \text{ solution set }& \text{ simplified }\\ \hline x^2-3x+2=0 &X=\{x:\ x^2-3x+2=0 \} & =\{1,2\}; \\ x^2=1 &Y=\{x:\ x^2=1 \}& = \{-1,1\}. \\ \end{array}$$ What if we have both equations to be satisfied at the same time? We are interested in the set: $$\begin{array}{llcll} Z&=\{x:\ x^2-3x+2=0 &\texttt{ AND }& x^2=1\}\\ &&& \Longrightarrow & x \text{ belongs to both }X\ \texttt{ AND }\ Y!\\ Z&=X&\cap&Y \\ &= \{x:\ x^2-3x+2=0\}&\cap&\{x:\ x^2=1\} \\ &= \{1,2\}&\cap&\{-1,1\}\\ &=\{1\}. \end{array}$$ $\square$

Warning: don't confuse an element of a set and a one-element set.

So, sometimes the condition that define the set splits into two conditions, $$Z=\{x:\ \text{ satisfies first condition }\texttt{ AND } \text{ satisfies second condition }\}.$$ The word “$\texttt{AND}$” is capitalized in order to emphasize that the set contains only those $x$'s that satisfy both conditions simultaneously. Then we can see also that there are two sets, $$X=\{x:\ \text{ satisfies first condition }\} \text{ and } Y=\{x:\ \text{ satisfies second condition }\},$$ one for either condition. We are interested in their intersection: $$Z=X\cap Y=\{x:\ \text{ satisfies first condition }\} \cap \{x:\ \text{ satisfies second condition }\}.$$

Example (inequalities). These conditions can also be inequalities. Let's consider this “double inequality”: $$0\le x \le 3.$$ Its solutions set is all $x$'s that satisfy the inequality. However, there are two in reality. When there are two inequalities, there are two solution sets: $$\begin{array}{llcll} &\{x:\ 0\le x \le 3\}\\ =&\{x:\ x\ge 0 &\texttt{ AND }& x\le 3\}\\ =& \{x:\ x\ge 0\}&\cap&\{x:\ x\le 3\} \\ =& [0,+\infty)&\cap &(-\infty,3]\\ =&[0,3]. \end{array}$$

We see intersection as an “overlap” of these subsets. What if we “flip” this inequality: $$0\ge x \ge 3.$$ Then, $$\begin{array}{llcll} &\{x:\ 0\ge x \ge 3\}\\ =&\{x:\ x\le 0 &\texttt{ AND }& x\ge 3\}\\ =& \{x:\ x\le 0\}&\cap&\{x:\ x\ge 3\} \\ =& (-\infty,0]&\cap &[3,+\infty)\\ =&\emptyset. \end{array}$$ $\square$

Exercise. What happens if you flip only one of the two inequalities above?

In summary: $$\{x:\ \text{ first condition }\texttt{ AND } \text{ second condition }\}=\{x:\ \text{ first condition }\} \cap \{x:\ \text{ second condition }\}.$$

We next consider subsets of the plane.

Example (graphs). All the graphs (of both relations and functions) are subsets of ${\bf R}^2$. For example, these are a few graphs of some relations, such as $x^2+y^2=k$ for the concentric circles:

The intersection of any two of them (for two different values of $k$) is empty. $\square$

Example (intercepts). For a function $F:{\bf R}\to {\bf R}$, its graph is the following set given presented via the set-building notation: $$\{(x,y):\ y=F(x)\}.$$ Two especially important subsets of the plane are the two axes.

Suppose $y=F(x)$ is a numerical function. Then the $x$-intercepts of $F$ are the elements of the intersection of the graph of $F$ with the $x$-axis: $$\{x\text{-intercepts}\}=\text{graph of }F\ \cap\ x\text{-axis}.$$ Meanwhile, the $y$-intercept of $F$ is the only element of the intersection of the graph of $F$ with the $y$-axis: $$\{y\text{-intercept}\}=\text{graph of }F\ \cap\ y\text{-axis}.$$ $\square$

Exercise. Give example of functions for which these sets are empty.

Exercise. Explain these: $$x\text{-axis}\ \cap\ y\text{-axis}\ \text{ and }\ \{x\text{-intercepts}\}\cap \{y\text{-intercept}\}.$$

Example (mixtures). Recall an example from Chapter 2: is it possible to create, from the Kenyan coffee - $\$2$per pound -- and the Colombian coffee -$\$3$ per pound, $6$ pounds of blend with the total price of $\$14$? The result is two linear relations each representing a line on the$xy$-plane: $$\begin{cases} x&+&y &= &6 ,\\ 2x&+&3y &= &14. \end{cases}$$ So, the intersection is a point and this point$(x,y)$is the solution of the system of equations formed by these two equations. Just as before, when there are two equations, there are two sets: $$\begin{array}{llcll} &\{(x,y):\ x+y = 6 &\texttt{ AND }&\qquad\qquad2x+3y = 14\}\\ =& \{(x,y):\ x+y = 6\}&\cap&\{(x,y):\ 2x+3y = 14\}\\ =&\{(4,2)\}. \end{array}$$ The intersection is a single point! The existence of an intersection point tells us that it is possible to create such a blend! However, if the Colombian coffee is also priced at$\$2$ per pound, there is no such mixture: $$\{(x,y):\ x+y = 6\} \cap \{(x,y):\ 2x+2y = 14\}=\emptyset.$$

The third possibility occurs when we change, in addition, the total price of the blend to $\$12$: $$\{(x,y):\ x+y = 6\} \cap \{(x,y):\ 2x+2y = 12\}=\{(x,y):\ x+y = 6\}.$$ There are infinitely many possible mixtures.$\square$Exercise. Illustrate the second and third possibilities in the last example. Exercise. Find the algebraic representations of these two lines and repeat the analysis above: Exercise. Evaluate: $$\{(x,y):\ y\ge f(x)\} \cap\{(x,y):\ y\le f(x)\}.$$ More examples of these two operations for subsets of the plane: These may also serve as illustrations of unions and intersections of “generic” sets. ## 2 Piece-wise defined functions Suppose one person knows only the preferences of Tom, Ned, and Ben, i.e., function$F$, and suppose another person knows only the preferences of Ben, Ken, and Sid, i.e., function$G$. Can the two pool their knowledge together in a meaningful way? This amounts to building a new function from two old ones: Of course, this is only possible if the data of ones isn't in conflict with that of the other (that's Ben). Otherwise we would end up with two arrows originating from the same input; not a function! So, we have two observations. • 1. We define the new function the domain of which is the union of the domains of the two functions. • 2. It is only possible as long as the values of the two functions on the intersection of their domains are the same. The two domains become the two pieces of the domain of the new function. Definition. Let$A,B$be two subsets of a set$X$such that$X = A \cup B$and let$Y$also be a set. Suppose also that$F: A \to Y,\ G:B\to Y$are two functions. A function$f:X\to Y$defined by: •$f(x)=F(x)$if$x$is in$A$, •$f(x)=G(x)$if$x$is in$B$, is called the piece-wise defined function of$F$and$G$. Since$f$is assumed to be a function, we are supposed to have one$y$for each$x$in the domain. Therefore: $$F(x)=G(x),\text{ for all } x \text{ in } A\cap B.$$ Exercise. What if the codomains are also different? We can just merge the tables of these functions: We can also superimpose the graphs of these functions: The algebraic notation for this function puts the formulas before the conditions: $$f(x)=\begin{cases} F(x) & \text{ if } x\text{ in } A; \\ G(x) & \text{ if } x\text{ in } B. \end{cases}$$ As it is often the case in algebra, the formula is to be read from right to left; i.e., $$\begin{cases} \text{ if } x\text{ in } A,& \text{compute }& f(x)=F(x); \\ \text{ if } x\text{ in } B,& \text{compute }& f(x)=G(x). \end{cases}$$ Example (graphs). In case of numerical functions, the graphs of two functions can be “glued together” (or rather “two wires soldered together”) to create a new function, as follows. The construction can fail:$\square$When there is no intersection of the domains, $$A\cap B=\emptyset,$$ there is no issue! Often however, we don't want to deal with the intersection and instead choose to glue together functions the domains of which has no intersection. It's especially true when there are more than two functions. We use the following notation (left): $$f(x)= \begin{cases} F_1(x) & \text{ if } x\text{ in } A_1; \\ F_2(x) & \text{ if } x\text{ in } A_2; \\ F_3(x) & \text{ if } x\text{ in } A_3; \\ ... &...\qquad; \end{cases}\quad\text{ means }\begin{cases} \text{ if } x\text{ in } A_1,& \text{compute }& f(x)=F_1(x); \\ \text{ if } x\text{ in } A_2,& \text{compute }& f(x)=F_2(x); \\ \text{ if } x\text{ in } A_3,& \text{compute }& f(x)=F_3(x); \\ ... &...\qquad. \end{cases}$$ provided$A_i\cap A_j=\emptyset$for$i\ne j$. With multiple sets, the “pieces” of the domain are introduced as conditions to be satisfied. Example (income tax). Suppose, hypothetically, that the tax code says: • if your income is less than$\$10000$, there is no income tax;
• if your income is between $\$ 10000$and$\$20000$, the tax rate is $10\%$;
• if your income is over $\$ 20000$, the tax rate is$20\%$. Let's build a function! Let$x$be the input (the income) and$y=f(x)$output (tax rate). Let the domain be$[0,+\infty)$. We choose the codomain to be$[0,1]$. The three “brackets” are the subsets of the domain. Since the values are different, we need to make sure that there is no overlap between the “pieces”: • if$0\le x\le 10000$, then$y=0$; • if$10000< x\le 20000$, then$y=.10$; • if$20000< x$, then$y=.20$. Let's build a flowchart. In contrast to most past examples, there is a fork on the road this time. The way we answer these questions about$x$determines the route for our computation: $$\begin{array}{ccc} f:& x & \mapsto & \begin{array}{|c|}\hline &x& \begin{array}{ll} \nearrow_{\text{ if }x\le 10000} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }0 \quad \\ \hline\end{array} & \mapsto & y & \searrow\\ \to_{\text{ if }10000< x\le 20000} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }.10 \quad \\ \hline\end{array} & \mapsto & y & \to\\ \searrow_{\text{ if }20000< x} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }.20 \quad \\ \hline\end{array} & \mapsto & y & \nearrow\\ \end{array}& y\\ \hline\end{array} & \mapsto & y \end{array}.$$ We also express the tax rate algebraically: $$f(x) = \begin{cases} 0 & \text{if } x \le 10000; \\ .10 & \text{if } 10000 < x \le 20000; \\ .20 & \text{if } 20000 <x. \end{cases}$$ This formula, however, cannot be applied directly to calculate your tax bill; indeed, if your income rises from$\$10,000$ to $\$ 10,001$, your tax bill would rise from$\$0$ to $\$ 1,000$. This is the issue of “discontinuity” discussed in Chapter 6. More realistically, the output of the formula represents a “marginal” tax rate: the rate you apply to that part of the income that lies within the bracket. These three numbers are then added together to produce your tax bill.$\square$Exercise. Find the formula of the tax bill. Hint: its graph is shown above on right. Some of very important functions are presented by several formulas at the same time. The next function is meant to give the direction from the origin to the location given by the input number: •$3$is to the right of$0$, so the direction is positive; and we say “it's$1$”; •$-5$is to the left of$0$, so the direction is negative; and we say “it's$-1$”. Definition. The sign function, which is denoted by $$y=\operatorname{sign}(x),$$ is defined as follows: • if$x<0$, then$y=-1$; • if$x=0$, then$y=0$; • if$x>0$, then$y=1$. If we think of a function as a sequence of steps, this is the case when the sequence splits; this is its flowchart: $$\begin{array}{ccc} y=\operatorname{sign}(x):& x & \mapsto & \begin{array}{|c|}\hline &x& \begin{array}{lllll} \nearrow_{\text{ if }x< 0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }-1 \quad \\ \hline\end{array} & \mapsto & y & \searrow\\ \to_{\text{ if }x=0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }0 \quad \\ \hline\end{array} & \mapsto & y & \to\\ \searrow_{\text{ if }x>0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }1 \quad \\ \hline\end{array} & \mapsto & y & \nearrow\\ \end{array}& y\\ \hline\end{array} & \mapsto & y \end{array}.$$ This is the algebraic formula: $$\operatorname{sign}(x)=\begin{cases} -1&\text{ if } x<0,\\ 0&\text{ if } x=0,\\ 1&\text{ if } x>0. \end{cases}$$ In other words, the function strips the input number off its magnitude and what's left is its sign, which is, in a way, its direction. Note how in this example there are three doors with specific values behind each and the only job of$x$is to point us at the right door. It is clear that the implied domain of this function is${\bf R}=(-\infty,+\infty)$. Since the only possible values are listed in the description of the function, the image is the set of these three,$\{-1,0,1\}$. We see that also in the table of values of the sign function, the$y$-values: $$\begin{array}{c|ccc} x&-3&-2&-1&0&1&2&3\\ \hline y&-1&-1&-1&0&1&1&1 \end{array}$$ This is the result: This is not enough, however, in order to see what the graph is around$0$; we insert more points into the table: $$\begin{array}{c|ccc} x&-.8&-.6&-.4&-.2&0&.2&.4&.6&.8\\ \hline y&-1&-1&-1&-1&0&1&1&1&1 \end{array}$$ The outputs continue to be repeated! This is an indication that the graph is horizontal in those areas. As we plot those points, we realize that can't connect them into a “single curve”. If this function to represent motion, we'd teleport... This issue is discussed in Chapter 6. The next function is meant to give the distance from the location given by the input number to the origin: both$3$and$-3$are$3$units from the origin. The result is always positive (except for$0$itself). One would commonly say that “the minus sign is dropped”. Warning: We can't “drop the sign” of$-x$because$x$itself might be negative. How else do we make a negative number positive? We multiply it by$-1$! Definition. The absolute value function, which is denoted by $$y = |x|,$$ is computed as follows: • if$x<0$, then$y=-x$; • if$x=0$, then$y=0$; • if$x>0$, then$y=x$. This is its flowchart: $$\begin{array}{ccc} y=|x|:& x & \mapsto & \begin{array}{|c|}\hline &x& \begin{array}{lllll} \nearrow_{\text{ if }x< 0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ multiply by }-1 \quad \\ \hline\end{array} & \mapsto & y & \searrow\\ \to_{\text{ if }x=0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }0 \quad \\ \hline\end{array} & \mapsto & y & \to\\ \searrow_{\text{ if }x>0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ pass it } \quad \\ \hline\end{array} & \mapsto & y & \nearrow\\ \end{array}& y\\ \hline\end{array} & \mapsto & y \end{array}.$$ This is the algebraic formula: $$|x|=\begin{cases} -x&\text{ if } x<0,\\ 0&\text{ if } x=0,\\ x&\text{ if } x>0. \end{cases}$$ In other words, the function does the opposite of what the sign function does; it strips the input number off its sign, or direction, and what's left is its magnitude. Exercise. Show that the two functions above are related by the following identity: $$|x|=\operatorname{sign}(x)\cdot x.$$ Exercise. Explain the alternative method is of this function: • if$x \le 0$then$y = - x$; and • if$x \ge 0$then$y = x$. Exercise. Present a flowchart for this definition. It is clear that the domain of this function is${\bf R}=(-\infty,+\infty)$. To find the image (the range of values), we take into account these two facts: • the only possible values are non-negative (by design), • every non-negative number is its own absolute value. Therefore, the image is the set of all non-negative numbers,$[0,+\infty)$. We see that also in the table of values of the absolute value function, the$y$-values: $$\begin{array}{c|ccc} x&-3&-2&-1&0&1&2&3\\ \hline y&3&2&1&0&1&2&3 \end{array}$$ As we plot more and more of those points, we realize that -- in contrast to$y=\operatorname{sign}(x)$-- we can connect them into a “single curve”. However, this V-shaped curve is made of parts of two straight lines,$y=x$and$y=-x$, without any “smoothing”. If the function to represent motion, the change of direction would be abrupt or even instantaneous! This issue is discussed in Chapter 7. Exercise. What symmetry do you see in the graph? Another important piece-wise defined function is the following. Definition. The integer value function, which is denoted by $$y = [x],$$ is defined as the largest integer$y$less than or equal to$x$. In other words, given an input of$x$, let's describe a procedure for computing this function. We have for a given$x$: • Step 1: determine whether$x$is integer or not. • Step 2: if$x$is an integer, then set$y=x$; else decrease from$x$until meet an integer, set$y$equal that integer. For example, we have: $$[5]=5,\ [3.1]=[3.99]=3,\ [-4.1]=-5.$$ Exercise. Present a flowchart for this definition. It is clear that the domain of this function is all reals${\bf R}=(-\infty,+\infty)$. To find the image, we take into account these two facts: • the only possible values are integers (by design), • the integer value of every integer is that number. Therefore, the image is the integers${\bf Z}=\{...,-3,-2,-1,0,1,2,3,...\}$. We see that also in the table of values of this function, the$y$-values: $$\begin{array}{c|ccc} x&-3&-2&-1&0&1&2&3\\ \hline y&-3&-2&-1&0&1&2&3 \end{array}$$ This is not enough, however, in order to see what the graph is. All we see is just a sequence of points on the line$y=x$: We insert more points: $$\begin{array}{c|ccc} x&-3&-2.5&-2&-1.5&-1&-.5&0&.5&1&1.5&2&2.5&3\\ \hline y&-3&-3&-2&-2&-1&-1&0&0&1&1&2&2&3 \end{array}$$ The outputs are repeated! This is an indication that the graph is horizontal in those areas. As we plot those points, we realize that can't connect them into a “single curve”, again. Example. Note that by the “pieces” of a piece-wise defined function we refer to the subsets of the domain (the segments of the$x$-axis below). Meanwhile, the corresponding pieces of the graph don't have to fit together well:$\square$Exercise. Write a formula for the above graph. Example (plotting). Let's plot the graph of the piece-wise defined function: $$f(x) = \begin{cases} 3 - \frac{1}{2}x & \text{ for } x \leq 2, \\ 2x - 5 & \text{ for } x > 2. \end{cases}$$ We follow these steps: • 1. plot$y=3 - \tfrac{1}{2} x$; • 2. plot$y=3 - \tfrac{1}{2}x$with domain$x \leq 2$; • 3. plot$y=2x - 5$; • 4. plot$y=2x - 5$with domain$x > 2$; • 5. combine the plots from 2) and 4).$\square$Exercise. Make a flowchart, write a formula, and then plot the graph of the function$y=f(x)$, where$x$is time in hours and$y=f(x)$is the parking fee over$x$hours, which is computed as follows: free for the first hour, then$\$1$ per every full hour for the next $3$ hours, and a flat fee of $\$5$for anything longer. Exercise. Make a hand-drawn sketch of the graph of the function: $$f(x)= \begin{cases} -3 &\text{ if } x<0,\\ x^2 &\text{ if } 0\le x<1,\\ x &\text{ if } x>1. \end{cases}$$ Example. The flowcharts also help to visualize what happens inside the black box that is a function when we step outside the domain: $$\begin{array}{ccc} y=1/x:& x & \mapsto & \begin{array}{|c|}\hline &x& \begin{array}{lllll} \nearrow_{\text{ if }x\ne 0} &x \mapsto &\begin{array}{|c|}\hline\quad \text{ take its reciprocal } \quad \\ \hline\end{array} & \mapsto & y & \searrow\\ \\ \searrow_{\text{ if }x=0} & x\mapsto &\begin{array}{|c|}\hline\quad \text{ STOP! } \quad \\ \hline\end{array} & & & \\ \end{array}& y\\ \hline\end{array} & \mapsto & y \end{array}$$$\square$Exercise. Make a flowchart as above for$f(x)=\sqrt{x}$. Exercise. Make a flowchart and then provide a formula for the function$y=f(x)$that represents a parking fee for a stay of$x$hours. It is computed as follows: free for the first hour and$\$1$ per hour beyond.

## 3 Numerical functions are transformations of the real number line

...and vice versa.

When an abstract numerical function $y=f(x)$ is given to us without any prior background, it may be a good idea to create a tangible representation for it. The two main ways we are familiar with are these:

• 1. we think of the function as if it represents motion: $x$ time, $y$ location;
• 2. we plot the graph of the function on a piece of paper.

Let's set these aside for now and imagine a third approach:

• 3. we think of the function as a transformation of the real line.

First, let's go back to representing a numerical function as correspondence between the $x$ and the $y$-axis:

As you can see, these are the same axes we use to plot the graph, but they are arranged parallel to each other instead of perpendicular. The arrows tell us what happens to each number. But there is more to it: they also suggest what happens to the whole $x$-axis!

Let's consider something more specific:

We ask, what has happened to the $x$-axis under this transformation?

Warning: Above you see two ways to interpret the function: (1) arrows are between the $x$-axis and the intact $y$-axis or (2) we move the $y$-axis so that $y=f(x)$ is aligned with $x$. The approaches give two different, even opposite, answers to the question. We will follow the former.

To make this more tangible, we will think as if the whole $x$-axis is drawn on a pencil:

A transformation we start with is a “motion”, specifically, a shift. We simply slide the pencil horizontally. Furthermore, there is another pencil to be used for reference. The markings (i.e., its coordinate system) on the second pencil show the new locations of the points on the first. As an example, a shift of $3$ units to the right is shown below:

Generally,

• when shifted $k>0$ units right, point $x$ becomes $x+k=y$.

Warning: replace “right” with “up” if the axes are aligned vertically; it's the positive direction that matters.

In the meantime, what about shifting left? We have:

• when shifted $k>0$ units left, point $x$ becomes $x-k$.

Of course, we can combine the two statements:

• when shifted $k>0$ units right/left, point $x$ becomes $x\pm k$.


Next, what kind of motion is this: $$y=-x?$$ We plot the arrows:

To understand what is happening, we can imagine that we grab the $x$-axis with at two spots with two hands and then bring those two points to the assigned locations on the $y$-axis. We can almost see how the $x$-axis is rotated into the $y$-axis! This is a different kind of transformation, a flip. We lift, then flip the pencil with $x$-axis on it, and place next to another such pencil. This flip is shown below:


The transformations that don't distort the line are called motions. Then, motions are the left shift and the right shift (the magnitude may vary) and the flip (the center may vary).

Let's consider something else, how about a fold (not a motion anymore)? The axis isn't on a pencil anymore! It is a piece of wire:

We also approach these issue from the opposite direction: instead of asking what transformation this function represents, we ask what function represents this transformation? From the arrow diagram on right, we conclude that half of the $x$-axis flips and the other stays put. What is this? A function with ${\bf R}$ as the domain and $[0,+\infty)$ as the range? This is the absolute value function, $y=|x|$!

A new type of transformation is a stretch. The line isn't on a pencil or a wire anymore! It is a rubber string (with knots to mark locations):

We grab it by the ends and pull them apart in such a way that the origin doesn't move. For example, a stretch by a factor of $2$ is shown below:

We, once again, can imagine that we grab the $x$-axis at two spots and bring them to the assigned locations on the $y$-axis. This is indeed a uniform stretch because the distance between any two points doubles.

Exercise. What does $f(x)=-2x$ do to the $x$-axis?

Generally,

• when the line is stretched by a factor $k>1$, point $x$ becomes $x\cdot k$.

In the meantime, what about a shrink? We have:

• when the line is shrunk by a factor $k>1$, point $x$ becomes $x/k$.


Exercise. What is the meaning of $|m|$ in the transformation given by $f(x)=mx+b$?

Exercise. What is the meaning of $b$ in the transformation given by $f(x)=mx+b$?

Example (coloring). We will often color the numbers according to their values. This is the summary of the functions we have considered:

We also plot the graphs of these functions below:

$\square$

A very simple, but important, class of function is the constant functions, $f(x)=k$. What does this function do to the $x$-axis? There is only one output:

The real line is shrunk to a single point; we can call this transformation collapse.

It is, however, more typical to have a non-uniform stretching throughout the domain of a function because it is likely to be non-linear.

Example (list). Let's consider this function given by its values: $$\begin{array}{l|lllll} x&0&1&2&3&4&5&6&7&8&9&10\\ \hline y&0&2&5&7&8&8.5&8.5&8&7&4&2\\ \end{array}$$ We then assume that the function continues between these values in a linear fashion: the $1$-unit segments on the $x$-axis are stretched and shrunk at different rates, and the ones beyond $x=6$ are also flipped over:

We also plot the graph of this function on right. So, at its simplest, a non-linear function is a combination of linear patches. $\square$

Exercise. Represent the following function given by its values as a transformation: $$\begin{array}{l|lllll} x&0&1&2&3&4&5&6&7&8&9&10\\ \hline y&6&5&4&3&3&3&4&5&6&6&6\\ \end{array}$$

Exercise. Make up your own function by its values and then represent it as a transformation. Repeat.

Example (fixed point). The stretch/shrink rates can also change continuously. To illustrate these basic transformations, we can also use a color representation of the real line. We can color locations at random; this is a combination of -- location dependent -- shifting, stretching, and shrinking:

Among all this complexity, the point marked with star is fixed. $\square$

Exercise. Sketch the graph of the function that represents the above transformation.

Example (graphs). The most common way to visualize a function remains its graph. The picture below shows how the two approaches come together. The transformation of the domain into the codomain performed by the function can be seen in what happens to its graph:

First, we take the $x$-axis as if it is a (colored) rope and lift it vertically (with some inevitable stretching) to the graph of the function and, second, we push it horizontally to the $y$-axis (practically, we shrink the image horizontally). At the end, we can see what has happened by considering what happens to these three intervals: stretching at the ends and shrinking in the middle. The transformation in the next example does more:

There is also a flip in the middle with a fold. $\square$

Exercise. Draw your own graph and then interpret the function as a transformation. Repeat.

Example (discontinuity). In general, a transformation can tear this rope:

We, however, will want to know when this happens. The issue of “continuity” is addressed in Chapter 6. $\square$

Exercise. Provide the graph of a function (a transformation) that tears this rope and then (a) pulls the two halves apart, (b) overlaps their ends.

Example (sign function). The sign function collapses the $x$-axis to three different points on the $y$-axis:

$\square$

Exercise. What does the integer value function $y=[x]$ do to the $x$-axis?

## 4 Functions with regularities: one-to-one and onto

We go back to functions that assign to each boy a ball to play with. In order for this to be a function, the table of this relation must have exactly one mark in each row:

It does but if we further study this function, we might notice two different but related “irregularities”.

First, no-one seems to like baseball! There is no arrow ending at the baseball and its column has no marks.

Let's modify the function slightly: Ken changes his preference from football to baseball. Then, there is an arrow for each ball and all columns in the table have marks.

In the graph, there is a dot corresponding to each horizontal line.

Definition. A function $F:X\to Y$ is called onto when there is an $x$ for each $y$ with $F(x)=y$.

The opposite is the sign that a potential output is “wasted”; some $y$ belongs to the codomain but not the image (the range of values).

Below, the reason for this terminology is explained:

We start with an element of $X$ and bring it -- along the arrow -- to the corresponding element of $Y$. The function is onto if all elements of $Y$ are covered.

Second, both Tom and Ben prefer basketball! The two arrows converge on the basketball and we can also see that its column has two marks. We note the same about the football.

The above function is modified: Tom and Ben have left. Then, no two arrows converge on one ball and no column has more than one mark.

In the graph, there can be only one, or none, dot corresponding to each horizontal line.

Definition. A function $F:X\to Y$ is called one-to-one when there is at most one $x$ for each $y$ with $F(x)=y$.

Below, the reason for this terminology is explained:

We start with an element of $X$ and bring it -- along the arrow -- to the corresponding element of $Y$. The function is one-to-one if every element of $Y$ is covered only once, if at all.

In summary, the two concepts are not about how many arrows originate from each $x$ -- it's always one -- but about how many arrows arrive at each $y$.

Now numerical functions. These functions are represented by their transformations and by their graphs. These two concepts will reveal whether the function is a kind we have discussed. We will assume below that

• the codomain the set of all reals ${\bf R}$.

We imagine that the $x$-axis, $X$, is transformed somehow and then placed on top of the $y$-axis, $Y$:

• onto: does $X$ cover the whole $Y$?
• one-to-one: does $X$ cover any location on $Y$ more than once?

Example (transformations). Let's consider the transformations from the last section. Their descriptions -- and illustrations -- tell the whole story. The left and right shifts, the flip, stretch, and the shrink -- are all both one-to-one and onto:

It is crucial though that the axes are infinite... What would make a transformation of an interval in the real line to be not one-to-one? Any folding present a visible problem:

And so does collapsing:

$\square$

Example (graphs). What about graphs? Let's start with this case: the domain is the reals $X={\bf R}=(-\infty, +\infty)$, while the codomain is the non-negative reals, $Y=[0,\infty)$. If the graph of a function $f:X\to Y$ is given, can we determine whether this function is one-to-one or onto by just examining the graph? The idea is to “sample” the function and see how the arrows behave:

If we notice that

• the arrows in the first row seem to cover the whole $Y$, while
• the arrows in the first column seem not to cover any location on $Y$ twice.

We conclude that these functions are onto and one-to-one, respectively. We make this conclusions with the understanding that they are based on the partial information provided by the graph. The case for not onto and not one-to-one is better; we can definitely see and mark with circles the following:

• the arrows in the second row missing a specific value in $Y$, and
• the arrows in the second column arriving to the same specific location.

$\square$

Exercise. How are the conclusions in the above example affected by different choices of (a) codomains, (b) domains.

Example (powers). Suppose this time the domain and the codomain are the reals, $X=Y={\bf R}$. Then the function $f(x)=x^{2}$ is not onto but $g(x)=x^{3}$ is. It is easy to prove the former: $$x^2\ne -1.$$ To prove the latter will require some algebra.

$\square$

Exercise. How can we “make” (a) $x^{2}$ or (b) $|x|$ onto?

What makes a difference? The graph doesn't progress below a certain line! The following is a useful observation:

• a function is onto if and only if its graph and any horizontal line have at least one point in common.

Example (powers). The function $f(x)=x^{2}$ is not one-to-one but $g(x)=x^{3}$ is. It is easy to prove the former: $$1^2=(-1)^2=1.$$ To prove the latter will require some algebra.

$\square$

Exercise. How can we “make” (a) $x^{2}$ or (b) $|x|$ one-to-one?

What makes a difference? Two points on the graph have the same height above the $x$-axis! The following is a useful observation:

• function is one-to-one if and only if the intersection of its graph and any horizontal line contains at most one point.

Notice the connection with the Vertical Line Test (is this a function?) from the Chapter 2:

Example (quadratic). Quadratic polynomials, $$F(x)=ax^2+bx+c,\ a\ne 0,$$ are neither one-to-one nor onto.

It will be proven in this chapter. $\square$

Exercise. Identify and classify the functions below:

Exercise. Function $y=f(x)$ is given below by a list of some of its values. Add missing values in such a way that the function is one-to-one. $$\begin{array}{r|l|l|l|l|l}x&-1 &0 &1 &2 &3 &4 &5\\ \hline y=f(x)&-1 & &4 &5 & &2 \end{array}$$

Exercise. What codomain of the function given above should we assume to assure that it is onto?

We summarize the results in the following important theorem.

THEOREM (Horizontal Line Test).

• (1) A function is onto if and only if its graph and any horizontal line have at least one point in common.
• (2) A function is one-to-one if and only if its graph and any horizontal line have at most one point in common.

In light of the theorem, we redo the table presented earlier by counting the number of intersections of horizontal lines with the graph:

In each cell of the table, we see an example of how -- in a simplest possible way -- these two conditions can be violated, for a numerical function.

Exercise. Illustrate each of the four possibilities above with a choice of a function given a list of values.

Linear functions are easy to characterize this way:

Indeed, as we know from geometry, two lines have exactly one intersection unless they are parallel; therefore the Horizontal Line Test is passed by all linear functions except the ones with zero slope. Those are constant functions.

However, we need to prove these facts algebraically.

Example (linear). Suppose we have a linear function with slope $3$ and $y$-intercept $2$, $$F(x)=3x+2.$$ Is it one-to-one? Suppose we have two inputs $x_1$ and $x_2$, can their outputs be equal under $F$? Let's try: suppose $F(x_1)=F(x_2)$. We substitute and obtain the following: $$3x_1+2=3x_2+2.$$ Cancelling $2$ produces the following: $$3x_1=3x_2.$$ Finally we divide by $3$: $$x_1=x_2.$$ No, the outputs are equal only when the inputs are!

Is it onto? Suppose we have an input $y$, is there an $x$ taken to $y$ under $F$? We just need to solve the equation $F(x)=y$ for $x$ for each $y$. In other words, we have an equation with an unspecified $y$: $$3x+2=y.$$ No matter what $y$ is, we subtract $2$ and then divide by $3$ producing: $$x=\frac{y-2}{3}.$$ Yes, there is such an $x$, for each $y$! $\square$

THEOREM (Linear functions). A linear function with slope $m$ and $y$-intercept $b$, $$F(x)=mx+b,$$ is both one-to-one and onto as long as $m\ne 0$.

Proof. One-to-one. Suppose we have two inputs $x_1$ and $x_2$. Then: $$F(x_1)=F(x_2)\ \Longrightarrow\ mx_1+b=mx_2+b\ \Longrightarrow\ mx_1=mx_2\ \Longrightarrow\ x_1=x_2.$$ It's the same input.

Onto. Suppose we have an input $y$. We solve the equation $F(x)=y$ for $x$: $$mx+b=y\ \Longrightarrow\ x=\frac{y-b}{m}.$$ There is such an $x$. $\blacksquare$

The picture confirms the conclusion:

Exercise. Prove algebraically that $f(x)=1/x$ is one-to-one but not onto.

Exercise. Classify the function $f(x)=x^3-x$ according to these two definitions. Prove algebraically.

THEOREM. (a) A function $F:X\to Y$ is onto if and only if its image is the whole codomain, $Y$. (b) A function $F:X\to Y$ is on-to-one if and only if the pre-image of every element of the codomain $Y$ is a single element of the domain, $X$.

Exercise. Prove the theorem.

To summarize, the restrictions in these definitions can be violated when there are too few or too many arrows arriving to a given $y$. These violations are seen in the co-domain. This one is not onto:

That one is not one-to-one:

Example (both). What functions are the most “regular”? The ones that are both one-to-one and onto, sometimes called bijections:

They may look plain but they have an interesting feature: the boys and the balls can be used as substitutes of each other! For example, you don't have to remember the name of every boy but just say “the one that plays basketball” to identify Tom without a chance of confusion... $\square$

Exercise. What are the smallest set $X$ and the smallest set $Y$ for which a function $F:X\to Y$ can be not one-to-one, not onto?

Exercise. Sketch the graph of the function $f$ given by its list of values below. Is it one-to-one? $$\begin{array}{r|ll} x&1&2&3&4&5\\ \hline y=f(x)&1&2&0&3&1 \end{array}$$

Exercise. Make up your own functions by providing their lists of values and test the two definitions. Repeat.

Example (power functions). All power functions, $$y=x^n,\ n=...,-3,-2,-1,0,1,2,3,...,$$ can now be classified:

$\square$

Exercise. Which ones are onto?

Exercise. What is the relation between being one-to-one and having a mirror symmetry?

Exercise. What kind of function is “many-to-one”? What about “one-to-many”?

## 5 Compositions of functions

Back in our boys-and-balls example, let's note the colors of the balls. This has nothing to do with the boys and it creates a new function:

It is a function $G:Y\to Z$ from the set of all balls to the new set $Z$ of the main colors. (Note that the new function is one-to-one but not onto.)

Since we also know the boys' preferences in balls, we can answer the question about their preferences in colors! We just need to combine the new function with the old:

If we start with a boy on the left, we can continue with the arrows all the way to the right. This way, we will know the color of the ball the boy is playing with:

This is a new function, say $H:X\to Z$, from the set of boys to the set $Z$ of the main colors:

(Note that the new function is neither one-to-one nor onto.)


Definition. Given two functions (with the codomain of the former matching the domain of the latter), $$F:X\to Y \text{ and } G:Y\to Z,$$ their composition is the function (from the domain of the former to the codomain of the latter) $$H:X\to Z,$$ denoted by: $$G\circ F,$$ which is computed for every $x$ in $X$ according to the following two-step procedure: $$x\mapsto F(x)=y \mapsto G(y)=z;$$ i.e., the new function is given by the substitution formula: $$z=H(x)=G(F(x)).$$

We just follow from $X$ along the arrows of $F$ to $Y$ and then along the arrows of $G$ to $Z$:

This is the “deconstruction” of the notation: $$\begin{array}{lll} &&\text{names of the second and first functions}\\ &&\downarrow\qquad\downarrow\\ \big(\ G\circ F\ \big)\ (x)&=&G \big(\quad F\ (x)\quad\big)\ .\\ \qquad\uparrow&&\qquad\uparrow\quad\uparrow\quad\uparrow\\ \text{name of the new function}&&\quad\text{substitution} \end{array}$$



If we think of functions as lists of instructions, we just attach the list of the latter at the bottom of the list of the former. In other words, here is the list of $G\circ F$:

• step 1: do $F$,
• step 2: do $G$.

They are executed consecutively: you can't start with the second until you are done with the first.

Let's test that on running example. We take the two lists of values and then cross-reference them (from left to right): $$\begin{array}{lll} F(\text{ Tom })&=\text{ basketball },\\ F(\text{ Ned })&=\text{ tennis },\\ F(\text{ Ben })&=\text{ basketball },\\ F(\text{ Ken })&=\text{ football },\\ F(\text{ Sid })&=\text{ football };\\ \end{array}\qquad\begin{array}{lll} G(\text{ basketball })&=\text{ orange },\\ G(\text{ tennis })&=\text{ yellow },\\ G(\text{ football })&=\text{ brown },\\ G(\text{ baseball })&=\text{ white }.\\ \end{array}$$ We ignore any alignment between the two lists. We take the first entry in the second list, $$G(\text{ basketball })=\text{ orange },$$ and replace “basketball”, according to the first entry of the first list, with $F(\text{ Tom })$. This is the result: $$G(\ F(\text{ Tom })\ )=\text{ orange }.$$ Therefore, $$H(\text{ Tom })=\text{ orange }.$$ This is the first entry in the new list...

Exercise. Finish the list.

Once again, algebraically, composition is nothing but substitution!

Example (numerical functions). This substitution is just as simple for numerical functions. For example,

• $y=x^2$ is substituted into $z=y^3$ resulting in $z=\big(x^2\big)^3$.

The idea remains the same: insert the input value in all of these boxes. For example, this function on the left is understood and evaluated via the diagram on the right: $$f\left(y \right)=\frac{2y^2-3y+7}{y^3+2y+1},\quad f\left( \square \right)=\frac{2\square^2-3\square+7}{\square^3+2\square+1}.$$ In Chapter 2, we inserted $3$ at each of these windows: $$f\left( \begin{array}{|c|}\hline\ 3 \ \\ \hline\end{array} \right)=\frac{2\begin{array}{|c|}\hline\ 3 \ \\ \hline\end{array}^2-3\begin{array}{|c|}\hline\ 3 \ \\ \hline\end{array}+7}{\begin{array}{|c|}\hline\ 3 \ \\ \hline\end{array}^3+2\begin{array}{|c|}\hline\ 3 \ \\ \hline\end{array}+1}.$$ This was the substitution $y=3$. This time, let's insert $\sin x$, or, better, $(\sin x)$. This is the substitution $y=\sin x$: $$f \begin{array}{|c|}\hline\ (\sin x) \ \\ \hline\end{array} =\frac{2\begin{array}{|c|}\hline\ (\sin x) \ \\ \hline\end{array}^2-3\begin{array}{|c|}\hline\ (\sin x) \ \\ \hline\end{array}+7}{\begin{array}{|c|}\hline\ (\sin x) \ \\ \hline\end{array}^3+2\begin{array}{|c|}\hline\ (\sin x) \ \\ \hline\end{array}+1}.$$ Then, we have $$f\left(\sin x \right)=\frac{2(\sin x)^2-3(\sin x)+7}{(\sin x)^3+2(\sin x)+1}.$$ Note that if you don't know what $\sin$ does, it makes no difference! The only thing that matters is that we know that this is a function. $\square$

Example (tables). Next, what about representing functions by their tables? These are the tables of $F$ and $G$ above:

How do we combine them to find $H$? The alignment we might see is meaningless. We need to align what the two have in common, $Y$. Then we start with an $x$ in $X$, use $F$ to find the corresponding value of $y$ in $Y$, then use $G$ to find the corresponding value of $z$ (one such step is illustrated below):

$\square$

Example (graphs). What if we have only their graphs? Suppose we have the two graphs of $$u=f(x)\ \text{ and }\ y=g(y),$$ side by side and we need to find the composition, $g\circ f$. Let's take a single value: $$d=g(f(a)).$$ Then, we use the first graph to find $c=f(a)$ on the vertical axis, then travel all the way to the horizontal axis of the second, find the corresponding $c$ on it, and finally find $d=g(c)$ on the vertical axis.

Graphs don't do a very good job visualizing compositions... Alternatively, we match the output axis, $u$, of the first function with the input axis, $u$, of the second:

It's still quite complicated! $\square$

Example (transformations). What if we, instead, think of numerical functions as transformations? For example, consider this:

• if the first transformation is a stretch by a factor of $2$, and
• the second transformation is a stretch by a factor of $3$, then
• the composition of the two transformations is a stretch by a factor of $3\cdot 2=6$:

So, we just carry out two transformations in a row. Consider also this:

• if the first transformation is a shift (right) by a $3$, and
• the second transformation is a stretch by a flip, and
• the third transformation is a shift (right) by a $5$, then
• the composition does the following:

$\square$

Exercise. Illustrate, as above, the composition of: the shift left by $5$, stretch by $2$, and a flip.

Exercise. Illustrate -- as a transformation -- the composition of the two functions shown below:

If we think of functions as lists of instructions, then each of them is already a composition! The steps on the list are the functions the composition of which creates the function. For example,

• $F$: add $3$, multiply by $-2$, subtract $1$.

This is called a decomposition of $F$. If, furthermore, there is another function, say,

• $G$: subtract $2$, apply $\sin$,

we just add the latter list to the bottom of the former:

• $G\circ F$: add $3$, multiply by $-2$, subtract $1$, subtract $2$, apply $\sin$.

Of course, we can have compositions of many functions in a row as long the output of each function matches the input of the next.

It's as if the first function gives us direction to a destination and at that destination we receive the directions to our next destination. At that location, we get further directions, and so on...

We represent functions as black boxes that process the input and produce the output: $$\begin{array}{ccc} \text{input} & & \text{function} & & \text{output} \\ x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y\\ &&&&\text{input} & & \text{function} & & \text{output} \\ &&&&y & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & z\\ &&&&&&&&\text{input} & & \text{function} & & \text{output} \\ &&&&&&&&z & \mapsto & \begin{array}{|c|}\hline\quad h \quad \\ \hline\end{array} & \mapsto & u&. \end{array}$$ Because of the match, we can carry over the output to the next line -- as the input of the next function.


Example (flowchart). Such a decomposition will allow us to study the function one piece at a time:

$\square$


Exercise. Represent the function $h(x)=(x-1)^2+(x-1)^3$ as the composition $g\circ f$ of two functions $y=f(x)$ and $z=g(y)$.

Example (spreadsheet). This is how the composition of several functions represented by formulas is computed with a spreadsheet. We start with just a list of numbers in the first column. Then we produce the values in the next column one row at a time. How? We input a formula in the next column with a reference to the last one. For example, we have in the second and third columns respectively: $$\texttt{=RC[-1]*2},\quad \texttt{=RC[-1]+5}\ .$$ Each of the two consecutive columns is a list of values of a function, left:

If we hide the middle column, we have the list of values of the composition. We can have as many columns as we like. $\square$

Example (lists). What if the functions are given by nothing but their lists of values? Then we need find a match for the output of the first function among the inputs of the second. Given the tables of values of $f, g$, find the table of values of $f \circ g$: $$\begin{array}{l|ll} x&y=g(x)\\ \hline 0&1\\ 1&0\\ 2&2\\ 3&4\\ 4&2 \end{array}\qquad\circ\qquad \begin{array}{l|ll} y&z=g(y)\\ \hline 0&0\\ 1&3\\ 2&5\\ 3&1\\ 4&2 \end{array}\qquad = \qquad \begin{array}{l|ll} x&z=f(g(x))\\ \hline 0&?\\ 1&?\\ 2&?\\ 3&?\\ 4&? \end{array}$$ We need to fill the second column of the last table. First, we need to match the outputs of $f$ with the inputs of $g$.

Alternatively, we simply re-arrange the rows of $g$ according to the values of $y$ and then just remove the $y$-columns: $$\begin{array}{l|ll} x&y\\ \hline 0&1 \\ 1&0\\ 2&2\\ 3&4\\ 4&2 \end{array} \begin{array}{l|ll} y&z\\ \hline 1&3\\ 0&0\\ 2&5\\ 4&2\\ 2&5 \end{array}\quad\leadsto\quad\begin{array}{l|ll} x&z\\ \hline 0&3 \\ 1&0\\ 2&5\\ 3&2\\ 4&5 \end{array}$$ $\square$

Exercise. Given the tables of values of $f, g$, find the table of values of $f \circ g$: $$\begin{array}{l|ll} x&y=g(x)\\ \hline 0&0\\ 1&4\\ 2&3\\ 3&0\\ 4&1 \end{array}\qquad\circ\qquad \begin{array}{l|ll} y&z=g(y)\\ \hline 0&4\\ 1&4\\ 2&0\\ 3&1\\ 4&2 \end{array}\quad = \quad ?$$

For example, the search may be executed with this formula: $$\texttt{=VLOOKUP(RC[-6],R3C[-4]:R18C[-3],2)}.$$ $\square$

Example (bad substitution). You may encounter problems stated as follows:

• “Find the composition $f \circ g$ of the functions:

$$f(x) = \frac{x}{1 + x},\quad g(x) = \sin x.”$$ Since both function have the same input variable, it might be unclear how to substitute! Let's sort this out.

The flowchart of the composition $f \circ g$ is: $$\begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & z &. \end{array}$$ This means that, in order to make the output of the first to match the input of the second, we had to rename the variables: $$\begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad \sin x \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad \dfrac{y}{1 + y} \quad \\ \hline\end{array} & \mapsto & z &. \end{array}$$ This is the new version of the problem:

• “Find the composition, $f \circ g$, of the functions:

$$f(y) = \frac{y}{1 + y},\quad y=g(x) = \sin x.”$$ Now we substitute $$y = \sin x\ \text{ into }\ f(y)=\frac{y}{1 + y},$$ as follows: $$\begin{array} {lll} (f \circ g )( x ) & = f(g(x)) = f(y) \\ & = \dfrac{y}{1 + y } \\ & = \dfrac{\sin x}{1 + \sin x} . \end{array}$$

As an exercise, let's do the reverse:

• “Find the composition, $g \circ f$, of the functions:

$$y=f(x) = \frac{x}{1 + x},\quad g(y) = \sin y.”$$ The flowchart of the composition $g \circ f$: $$\begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & z &. \end{array}$$ Once again, we had to rename the variables: $$\begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad \dfrac{x}{1 + x} \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad \sin y \quad \\ \hline\end{array} & \mapsto & z &. \end{array}$$ Now we substitute $$y=\frac{x}{1 + x}\ \text{ into }\ g(y)=\sin y,$$ as follows: \begin{aligned} (g \circ f )( x ) & = g(f(x)) = g(y) \\ & = \sin\left( \frac{x}{1 + x }\right) . \end{aligned} $\square$

Exercise. Represent the function $h(x)=2\sin^3x+\sin x+5$ as the composition of two functions one of which is trigonometric. Hint: it doesn't matter what $\sin$ does.

Exercise. (a) Represent the function $h(x)=\sqrt{x-1}$ as the composition of two functions. (b) Represent the function $k(t)=\sqrt{t^2-1}$ as the composition of three functions. (c) Represent the function $p(t)=\sin\left(\sqrt{t^2-1}\right)$ as the composition of four functions.

Exercise. Functions $y=f(x)$ and $u=g(y)$ are given below by tables of some of their values. Present the composition $u=h(x)$ of these functions by a similar table: $$\begin{array}{r|c|c|c|c} x &0 &1 &2 &3 &4 \\ \hline y=f(x) &1 &1 &2 &0 &2 \end{array}$$ $$\begin{array}{c|c|c|c|c} y &0 &1 &2 &3 &4 \\ \hline u=g(y) &3 &1 &2 &1 &0 \end{array}$$

Exercise. Represent the composition of these two functions: $f(x)=1/x$ and $g(y)=\frac{y}{y^2-3}$, as a single function $h$ of variable $x$. Don't simplify.

Exercise. Function $y=f(x)$ is given below by a list of its values. Is the function one-to-one? $$\begin{array}{r|l|l|l|l|l}x&0 &1 &2 &3 &4 \\ \hline y=f(x)&0 &1 &2 &1 &2 \end{array}$$

## 6 The inverse of a function

Our main example of a function answers the question: which ball is this boy playing with?

What if we turn this around: which boy is playing with this ball?

The solution would seem to be a simple reversal of the arrows:

We can see that, even though the latter question is asked about the same situation as the former, it cannot be answered in a positive manner! Indeed:

• there is no boy playing with the baseball -- no answer.

This mean that there is no function this time!

All functions from $X$ to $Y$ are also relations between $X$ and $Y$. However, not every relation is a function -- either from $X$ to $Y$ or from $Y$ to $X$. The reasons are the same: too many or too few arrows starting at the domain set.

An especially important question is, can we reverse the arrows of a function so that that same relation is now seen as a new, “inverse”, function? The answer is No for all of the example. Why not?

• First, some $y$'s in $Y$ have no corresponding $x$'s in $X$. In other words, the function isn't onto!
• Second, some $y$'s in $Y$ have two or more corresponding $x$'s in $X$. In other words, the function isn't one-to-one!

So, the original function lacked either of the two types of regularity for this to be possible.

What kind of function would make this possible? A function that is both one-to-one and onto:

We have added an extra ball (soccer) and redrew the arrows: there is exactly one arrow for each ball. This is a very simple, almost uninteresting, kind of function. Indeed, each boy holds a ball and every ball is held by a boy. The difference is only in the name... Indeed, if you don't remember Tom's name, you just say “the boy who plays with a basketball”. Or, if you don't remember what that red ball is for, you just say “the game Sid plays". There is no ambiguity in this substitution.


THEOREM. A function is both one-to-one and onto if and only if it has an inverse.

Exercise. Prove the theorem.

Under this condition, the arrows can be safely reversed:

THEOREM. There is only one inverse for a function.

This justifies using “the inverse”.

Exercise. Prove the theorem.

The inverse of a function $F$ is denoted by: $$F^{-1}.$$ It is read “$F$ inverse”. Here “$F$” is the name of the old function and “$F^{-1}$” is the name of the new function.

Warning: the notation is not to be confused with the power notation for the reciprocal: $2^{-1}=\frac{1}{2}$. (Warning inside a warning: the inverse of multiplication is division.)

An idea to hold on to is that a function and its inverse represent the same relation between sets $X$ and $Y$:

• $x$ and $y$ are related when $y=F(x)$, or
• $x$ and $y$ are related when $x=F^{-1}(y)$.

The choice between $F$ and $F^{-1}$ is the choice the “roles” for $X$ and $Y$, input or output, domain or codomain.

Exercise. Explain the picture below:

What does this have to do with compositions? They allow us to make the informal idea of “reversing the arrows” fully precise.

Notice that the domain of the new function would have to be the codomain of the original! Their composition then makes sense:

We have made -- through this composition -- a full circle from boys to balls and back to boys. Every time, we arrive to our starting point, a boy.

There is another way to build a composition though!

We have made -- through that composition -- a full circle from balls to boys and back to balls. Every time, we arrive to our starting point, a ball.

Here is a flowchart representation of this idea: $$\begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad F \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad G \quad \\ \hline\end{array} & \mapsto & x &,\text{ same }x!\\ y & \mapsto & \begin{array}{|c|}\hline\quad G \quad \\ \hline\end{array} & \mapsto & x & \mapsto & \begin{array}{|c|}\hline\quad F \quad \\ \hline\end{array} & \mapsto & y &,\text{ same }y! \end{array}$$ We feed the output of $F$ into $G$ and vice versa.

THEOREM. Suppose $F:X\to Y$ is a function that is both one-to-one and onto. Then a function $G:Y\to X$ is the inverse of $F$ if

• $G(F(x))=x$ for all $x$, and
• $F(G(y))=y$ for all $y$.

Exercise. Prove the theorem.


Definition. A function that is both one-to-one and onto is also called invertible.

Such a function creates a correspondence between the two sets that it's as if this is the same set...

Exercise. Complete the sentence: “The set of all invertible functions from $X$ to $Y$ is the _____________ of the set of one-to-one functions and the set of onto functions.”

Now, the numerical functions...

Example (transformations). What is the meaning of the inverse of a function when seen as a transformation of the line? It is a transformation what would reverse the effect of the original.

Just by examining these simple transformations, we discover the following:

• the inverse of the shift $s$ units to the right is the shift of $s$ units to the left;
• the inverse of the flip is another flip;
• the inverse of the stretch by $k$ is the shrink by $1/k$.

In fact, we realize that they pair up:

• the shift $s$ units to the right and the shift of $s$ units to the left are the inverses of each other;
• the flip is the inverse with itself;
• the stretch by $k$ and the shrink by $1/k$ are the inverses of each other.


Example (lists). Suppose a function is given by its list of values: $$f=\begin{array}{|l|l|} x&y=f(x)\\ \hline 0&1\\ 1&0\\ 2&2\\ 3&1\\ 4&3\\ ...&... \end{array}\ =\ \begin{array}{|lll|} x&\to&y\\ \hline 0&\to&1\\ 1&\to&0\\ 2&\to&2\\ 3&\to&1\\ 4&\to&3\\ ...&...&... \end{array}.$$ The table is understood as if there are arrows going horizontally left to right. That is why “reversing the arrows” means interchanging the columns: $$f^{-1}=\begin{array}{|lll|} x&\to&y\\ \hline 0&\leftarrow&1\\ 1&\leftarrow&0\\ 2&\leftarrow&2\\ 3&\leftarrow&1\\ 4&\leftarrow&3\\ ...&...&... \end{array}\ =\ \begin{array}{|lll|} y&\to&x\\ \hline 1&\to&0\\ 0&\to&1\\ 2&\to&2\\ 1&\to&3\\ 3&\to&4\\ ...&...&... \end{array}\ =\ \begin{array}{|lll|} y&\to&x\\ \hline 0&\to&1\\ 1&\to&0\\ 1&\to&3\\ 2&\to&2\\ 3&\to&4\\ ...&...&... \end{array}\ =\ \begin{array}{|l|l|} y&x=f^{-1}(y)\\ \hline 0&1\\ 1&0\\ 1&3\\ 2&2\\ 3&4\\ ...&... \end{array}.$$ It may, or may not, become clear that the new function isn't a function! To make sure, it's a good idea to arrange the inputs in the increasing order. Then we clearly see the conflict: $f^{-1}(1)=0$ and $f^{-1}(1)=3$. The original function, $f$, wasn't one-to-one! $\square$

The general rule for finding the inverse of a function given by a formula follows from the definition:

• the inverse of $y=f(x)$ is found by solving this equation for $x$; i.e., $x=f^{-1}(y)$.

Example. To find the inverse of a linear polynomial $$f(x)=3x-7,$$ set and solve $$y=3x-7\ \Longrightarrow\ y+7=3x\ \Longrightarrow\ \frac{y+7}{3}=x.$$ Therefore, $$f^{-1}(y)=\frac{y+7}{3}.$$ If it is not known ahead of time if the function is one-to-one, this fact is established, automatically, as a part of the solution. For example, to find the inverse of the quadratic function $$f(x)=x^2,$$ set and solve $$y=x^2\ \Longrightarrow\ \pm\sqrt{y}=x.$$ The $\pm$ sign indicates that there are two solutions ($x>0$). The original function wasn't invertible! $\square$

A linear polynomial, $$f(x)=mx+b,$$ is one-to-one and onto whenever $m\ne 0$. Algebraically, we just solve the equation $y=mx+b$ for $x$. The algebraic result is below.

THEOREM (inverse of linear polynomial). The inverse of a linear polynomial $$f(x)=mx+b,\ m\ne 0,$$ is also a linear polynomial and its slope is the reciprocal of that of the original: $$f^{-1}(y)=\frac{1}{m}y-\frac{b}{m}.$$

So, the set of all linear polynomials is split into pairs: a steeper line and a shallower one ($2$ and $1/2$, $-2$ and $-1/2$, as well as $1$ with itself and $-1$ with itself):

Next, one can imagine how some new algebraic operations may have appeared. Some emerged as the abbreviations for repeated familiar operations; for example, repeated addition, $2 + 2 + 2 = 2 \cdot 3$, leads to a new operation: multiplication. Meanwhile, repeated multiplication, $2 \cdot 2 \cdot 2 \cdot 2 = 2^{4}$, leads to a new operation: exponent. But what about subtraction and division?


Analysis: $$\begin{array}{ccc} \text{time (hours)}& \xrightarrow{\ 60\text{ m/h }\ }& \text{distance (miles)}&\xrightarrow{\ 30\text{ m/gal }\ }& \text{gas used (gal)}& \xrightarrow{\ \ 5/ \text{ gal }}&\text{expense } (\) \\ t& \xrightarrow{\ f\ }& d&\xrightarrow{\ k\ }& g& \xrightarrow{\ h\ }&e \\ \end{array}$$ The functions: $$d = f(t) = 60t, \ g = k(d) = \frac{d}{30}, \ e = h(g) = 5g.$$ Substitution: $$\begin{array}{ll} g = k(d) & = k(f(t)) \\ e = h(g) & = h(k(d)) \\ & = h(k(f(t))) \end{array}$$ $\square$

Example. Find $f(g(x))$ and $g(f(x))$ with: $$f(x) = x^{2}\text{ and } g(x) = \cos x.$$ The problem may represent a challenge because the variables don't match!

First, to find $f(g(x))$, first re-write: $$f(y) = y^{2}\text{ and } y=g(x) = \cos x.$$ Then replace (substitute) $y$ in $f$ with $(\cos x )$, always with parentheses: $$y^{2} \leadsto ( \cos x )^{2},$$ or $\cos^{2} x$.

Second, to find $g(f(x))$, first re-write: $$y=f(x) = x^{2}\text{ and } g(y) = \cos y.$$ Then replace $y$ in $g$ with $(x^{2})$: $$\cos y \leadsto \cos (x^{2}).$$ $\square$

Example. When the two functions are represented by their tables of values, the composition can be computed just as with the rest of algebraic operations (as discussed later). It is more complex as we cannot simply go row by row adding the values. One has to find the right entry in the next function.

Suppose we need to compose these two functions: $$\begin{array}{c|cc} t&x=f(t)\\ \hline 0&1\\ 1&2\\ 2&3\\ 3&0\\ 4&1 \end{array}\quad \circ \quad \begin{array}{c|cc} x&y=g(x)\\ \hline 0&5\\ 1&-1\\ 2&2\\ 3&3\\ 4&0 \end{array}\quad=\quad ?$$ The result should be another table of values for the function $h=g\circ f$. To fill this table, we watch where every $t$ goes, after two steps: under $f$ we have $0\mapsto 1$, where does $1$ go under $g$? We look at the second table: under $g$ we have $1\mapsto -1$. Therefore, under $h$ we have $0\mapsto -1$. That gives us the first row in the new table. Furthermore: $$f:1\mapsto 2\quad g:2\mapsto 2\quad \Longrightarrow\ h:1\mapsto 2.$$ And so on. Some are shown below: $$\begin{array}{c|rcl|cll} t&x&&x&y\\ \hline 0&1&\searrow&0&5\\ 1&2&\searrow&1&-1& \Longrightarrow\ 0\mapsto -1\\ 2&3&\searrow&2&2& \Longrightarrow\ 1\mapsto 2\\ 3&0&&3&3& \Longrightarrow\ 2\mapsto 3\\ 4&1&&4&0 \end{array}$$ And this is the answer: $$\begin{array}{c|cc} t&x=f(t)\\ \hline 0&1\\ 1&2\\ 2&3\\ 3&0\\ 4&1 \end{array}\quad \circ \quad \begin{array}{c|cc} x&y=g(x)\\ \hline 0&5\\ 1&-1\\ 2&2\\ 3&3\\ 4&0 \end{array}\quad =\quad \begin{array}{c|cc} t&y=g(f(t))\\ \hline 0&-1\\ 1&2\\ 2&3\\ 3&5\\ 4&-1 \end{array}$$

$\square$

Functions represented by graphs can also be composed. The procedure is, however, more convoluted than for the rest of the algebraic operations.

Example. Suppose a car is driven through a mountain terrain. The location, as seen on a map, is known and so is the altitude for each location.

We set up two functions, for location and altitude, and their composition is what we are interested in:

The second function is literally the profile of the road.

Here,

• $t$ is time measured in $\text{hr}$;
• $x=f(t)$ is the location of the car as a function of time -- measured in $\text{mi}$;
• $y=g(x)$ is the altitude of the road as a function of (horizontal) location -- measured in $\text{ft}$; and
• $y=h(t)=g(f(t))$ is the altitude of the road as a function of time -- measured in $\text{ft}$.

$\square$

This is the familiar way to evaluate a function: $$f(x)=x^2-x\ \Longrightarrow\ f(3)=3^2-3.$$ There is also an alternative notation for substitution: $$f(x)=x^2-x\ \Longrightarrow\ f(3)=x^2-x\Bigg|_{x=3}=3^2-3.$$ This notation also applies to compositions. For example,

• we substitute $z=g(y)=y\cdot 2$ into $u=h(z)=z^2$, which results in the following:

$$u=z^2\Bigg|_{z=y\cdot 2}=(y\cdot 2)^2.$$

• we substitute $y=f(x)=x+3$ into $z=g(y)=y\cdot 2$, which results in the following:

$$z=y\cdot 2\Bigg|_{y=x+3}=(x+3)\cdot 2.$$

## 12 Solving equations

As explained in Chapter 2, to solve an equation with respect to $x$ means to find all values of $x$ that satisfy the equation. In other words, when we substitute those values into the equation we have a true statement. For example, consider how this equation is solved: $$x+2=5\ \Longrightarrow\ x=3.$$ This is an abbreviated version of the following statement:

• if $x$ satisfies the equation $x+2=5$ then $x$ satisfies the equation $x=3$.

Plug in: $$x+2=(3)+2=5.$$ It checks out! We could try others and they won't check out: $$\begin{array}{ll} x=0&(0)+2=2\ne 5&\text{No!}\\ x=1&(1)+2=3\ne 5&\text{No!}\\ x=2&(2)+2=4\ne 5&\text{No!}\\ x=3&(3)+2=5= 5&\text{Yes!}\\ x=4&(4)+2=6\ne 5&\text{No!}\\ \end{array}$$ Of course, this trail-and-error method is unfeasible because there are infinitely many possibilities.

A method of how we may arrive to the answer is discussed in this section.

As a reminder, in the special case when the right-hand side of the equation is zero, a solution to this equation has a clear geometric meaning: an $x$-intercept of a numerical function $f$ is any solution to the equation $f(x)=0$. In other words, these are the $x$-coordinates of the intersections of the graph with the $x$-axis:

When the right-hand side is a number, say, $k$, a solution to this equation $f(x)=k$ gives us an intersection of the graph with the line $y=k$.

Our interest in this section is algebra though... We will address a simple kind of equation:

• $x$ is present only once, in the left-hand side.

Starting with such an equation, our goal is -- through a series of manipulations -- to arrive to an equation with an isolated $x$. In other words, we will have only $x$ on the left and no $x$ on the right, like this: $$x=\sqrt{17}.$$

Warning: this is an equation.

Suppose we see a single $x$ “wrapped” in several layers of functions: $$3\cdot\left( \frac{\sqrt{x}}{4}+1\right)=6.$$ It's a composition of several functions applied to $x$. To get to it, we will need to remove these layers one by one. In what order? From the outside in, of course. We reverse the flowchart: $$\begin{array}{ccc} x & \to & \begin{array}{|c|}\hline\ \text{ root } \ \\ \hline\end{array} & \to & \begin{array}{|c|}\hline\ \text{divide by }4 \ \\ \hline\end{array} & \to & \begin{array}{|c|}\hline\ \text{add }1 \ \\ \hline\end{array} & \to & \begin{array}{|c|}\hline\ \text{multiply by }3 \ \\ \hline\end{array} & \to &6&;\\ x & \leftarrow & \begin{array}{|c|}\hline\ \text{ square } \ \\ \hline\end{array} & \leftarrow & \begin{array}{|c|}\hline\ \text{multiply by }4 \ \\ \hline\end{array} & \leftarrow & \begin{array}{|c|}\hline\ \text{subtract }1 \ \\ \hline\end{array} & \leftarrow & \begin{array}{|c|}\hline\ \text{divide by }3 \ \\ \hline\end{array} & \leftarrow &6&.\\ \end{array}$$ So, $x=\pm 2$!

Warning: this plan does not work for many familiar types of equations including quadratic equations.

The main idea is as follows:

• we apply a function to both sides of the equation producing a new equation.

For example, if we have an equation, say, $$x+2=5,$$ we treat it as a number, call it $y$. Then we deal with this number: $$y=x+2=5,\ \text{ apply }z=y-2\ \Longrightarrow\ (x+2)-2=3-2\ \Longrightarrow\ x=3.$$ The idea is to produce -- from an equation satisfied by $x$ -- another equation satisfied by $x$.


There are infinitely many possibilities for this function $g$ then: $$\begin{array}{rrcll} x+4=7 & & (x+2)^2=5^2 & & \sin (x+2)=\sin 5\\ & \nwarrow & \uparrow & \nearrow\\ x+5=8 & \leftarrow & \begin{array}{|c|}\hline \quad x+2=5 \quad \\ \hline\end{array} & \to & 2^{x+2}=2^5\\ & \swarrow & \downarrow & \searrow\\ x+6=9 & & (x+2)^3=5^3 & & \sqrt{x+2}=\sqrt{5}\\ \end{array}$$ If $x$ satisfies the equation in the middle, it also satisfies the rest of the equations.

If we want to solve the original equation, which function -- out of infinitely many -- do we pick? Some of them clearly make the equation more complex than the original! It is the challenge for the equation solver to have enough foresight to choose a function to apply that will make the equation simpler.

If between us and $x$ there is a function, we would like to remove it. How? The answer is, apply the inverse of the function that we face! We have for our equation: $$x\mapsto f(x)=x+2\ \Longrightarrow\ f^{-1}(y)=y-2.$$

Is applying the inverse of the function that contains $x$ in the equation a fool-proof plan? No. Try this: $$x^2=1, \text{ apply } z=\sqrt{y}\ \Longrightarrow\ \sqrt{x^2} =\sqrt{1}\ \Longrightarrow\ x=1??$$ We have lost $x=-1$! It satisfies the first equation but not the last. What happened? There is nothing wrong with the logic of applying the inverse and producing a new equation satisfied by $x$; however, the cancellation of the function and its “inverse” was incorrect. The square and the square root are inverses of each other (and cancel) only, separately, on the rays $[0,+\infty)$ and $(-\infty, 0]$. We disregarded the latter of these two cases: $$\text{case 1: }\ x\ge 0\ \Longrightarrow\ \sqrt{x^2}=x,\quad \text{case 2: }\ x\le 0\ \Longrightarrow\ \sqrt{x^2}=-x.$$ We can point out exactly why this failed; the function isn't one-to-one!

Example. What if we have several functions applied consecutively to $x$? Which function do we choose to apply? In the equation, $$5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big)-17=3,$$ the last operation on the left is $-17$. That's the function we face and the inverse of this function is applied. We choose: $$f(z)=z-17,$$ where $$z=5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big).$$ Then we apply $$f^{-1}(y)=y+17.$$ We conclude: $$z-17=3\ \Longrightarrow\ (z-17)+17=3+17\ \Longrightarrow\ z=20.$$ We have a new equation now: $$5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big)=20.$$ As we progress, we apply the inverse of the function that appear first in the equation (i.e., it is applied last). We have the following sequence of steps “unwrapping” the parentheses one pair at a time: $$\begin{array}{lclc} 5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big)=20& \Longrightarrow&5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big)/5=20 /5&\Longrightarrow&\\ \left( \frac{x}{2}+1\right)^2+3 =4 &\Longrightarrow&\left( \frac{x}{2}+1\right)^2+3-3 =4-3 &\Longrightarrow&\\ \left( \frac{x}{2}+1\right)^2 =1 &\Longrightarrow&\sqrt{\left( \frac{x}{2}+1\right)^2} =\sqrt{1} &?\Longrightarrow?&\\ \frac{x}{2}+1 =1 &\Longrightarrow&\frac{x}{2}+1-1 =1-1&\Longrightarrow& \\ \frac{x}{2} =0 &\Longrightarrow&\frac{x}{2} \cdot 2=0\cdot 2 &\Longrightarrow&\\ x =0. \\ \end{array}$$ But $x=-4$ is also a solution! What happened? We disregarded the latter of these two cases: $$\text{case 1: }\ z\ge 0\ \Longrightarrow\ \sqrt{z^2}=z,\quad \text{case 2: }\ z\le 0\ \Longrightarrow\ \sqrt{z^2}=-z.$$ We then re-do the solution starting at the question mark. The equation produces two cases: $$\begin{array}{rcl} &\sqrt{\left( \frac{x}{2}+1\right)^2} =\sqrt{1}\\ \swarrow&&\searrow\\ \end{array}$$ $$\begin{array}{lll|c|ll} z=\frac{x}{2}+1\ge 0&&&\texttt{ OR }&z=\frac{x}{2}+1\le 0\\ \hline \left( \frac{x}{2}+1\right)^2 &=1 &\Longrightarrow&\texttt{ OR }&-\left( \frac{x}{2}+1\right)^2 &=1 &\Longrightarrow&\\ \frac{x}{2}+1 &=1 &\Longrightarrow&\texttt{ OR }&\frac{x}{2}+1 &=-1 &\Longrightarrow \\ \frac{x}{2} &=0 &\Longrightarrow&\texttt{ OR }&\frac{x}{2} &=-2 &\Longrightarrow&\\ x &=0&&\texttt{ OR }&x&=-4. \\ \end{array}$$ Both $x=1$ and $x=-4$ satisfy their respective conditions. Therefore, the solution set is $\{1,-4\}$... unless we have missed a few solutions on the way! The issue is addressed in this section. $\square$

Exercise. Solve the equation: $$5\cdot\Big( \left( \frac{x^2}{2}+1\right)^2+3 \Big)-17=3.$$

Exercise. Solve the equation: $$\left( 5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big)-17\right)^3=27.$$ Make up your own equation and solve it. Repeat.

Is applying the inverse of the function that contains $x$ in the equation -- making sure that it is one-to-one -- a fool-proof plan? No. Try this: $$\sqrt{x}=-1, \text{ apply } z=y^2\ \Longrightarrow\ \left( \sqrt{x} \right)^2 =(-1)^2\ \Longrightarrow\ x=1??$$ We have a solution where there is none! It satisfies the last equation but not the first. What happened? There is nothing wrong with our logic; however, the cancellation of the function and its “inverse” was incorrect, once again. The square and the square root are inverses of each other (and cancel) only, separately, on the rays $[0,+\infty)$ and $(-\infty, 0]$. We can point out exactly why this failed; the function isn't onto!

Example. Consider the equation: $$\sqrt{x+1}=3.$$ Examining the equation, we see $x$ on left only and it is subjected to two functions, the last of which is the square root. Therefore, to make a step toward isolating $x$, square both sides: $$\left( \sqrt{x+1} \right)^2=3^2.$$ If we were to cancel the two functions on left as inverses, we get this new equation: $$x+1=9.$$ The solution is $x=8$... but was the cancellation valid? We just need to confirm that the solution falls within the domain -- $x+1\ge 0$ -- of the original equation. It does. $\square$

Exercise. Solve the equation: $$\sqrt{x^2+1}=3.$$

Exercise. Solve the equation: $$5\sqrt{x+1}=3.$$ Make up your own equation and solve it. Repeat.

Using only invertible functions ensures that we don't lose solutions or gain non-solutions. This is why this approach will often allow us to enhance our solution method: from

• “if $x$ satisfies an equation then it satisfies the next”, to
• “$x$ satisfies an equation if and only if it satisfies the next”.

In other words, the latter contains both the former and its converse!

The advantage of this approach is that the equations will have the same solution set as we progress through the stages. For example, this how we would rather present the solution of the very first equation in this section: $$x+2=5\ \Longleftrightarrow\ x=3.$$ This is an abbreviated version of the following statement:

• $x$ satisfies $x+2=5$ if and only if $x$ satisfies $x=3$.

Repeated as many times as necessary, the solution set of each equation is the same as that of the original equation!

Example. Two complete solutions are below: $$\begin{array}{lll} 2(x+2)-3=5x\ \Longleftrightarrow\ 2x+4-3=5x\ \Longleftrightarrow\ -3x=-1\ \Longleftrightarrow\ x=1/3;\\ x^2+1=0\ \Longleftrightarrow\ x^2=-1\ \Longleftrightarrow\ \emptyset. \end{array}$$ $\square$

So, to solve the type of equation we face -- a variable $x$ subjected to a sequence of functions -- we apply the inverses of these functions in the reversed order. We may have to split the domains of the functions so that they are both one-to-one and onto. As we have seen, this step also splits our equation.

Example. A solution is below: $$\begin{array}{lll} x^2=1\ \Longleftrightarrow\ x=-1\ \texttt{ OR }\ x=1. \end{array}$$ $\square$

Exercise. Solve the equation in this manner: $$\sqrt{x+1}=3.$$

Exercise. Solve the equation in this manner: $$\sqrt{x^2+1}=3.$$ Make up your own equation and solve it. Repeat.

Example. What if, instead of a single $x$, we face an expression that depends on $x$? For example, we might face this: $$5\cdot\Big( \left( x^2+x+1\right)^2+3 \Big)-17=3.$$ But what is an “expression” if not just another variable, $y=x^2+x+1$, represented (expressed) as a function of $x$. To make this choice clear, we substitute: $$5\cdot\Big( (y)^2+3 \Big)-17=3.$$ In that we case, we go after this variable, $y$, by following the same plan as before: remove these layers one by one. Once $y$ is found (as in the example), you have a much simpler equation, or equations, for $x$: $$x^2+x+1 =1\ \texttt{ OR }\ x^2+x+1=-4.$$ $\square$

Exercise. Finish the solution. Make up your own equation and solve it. Repeat.

Example. Another solution is below: $$\begin{array}{lll} \sqrt{x^2-3x+2}=0\ \Longleftrightarrow\ \sqrt{y}=0\ \texttt{ AND }\ y=x^2-3x+2\\ \Longleftrightarrow\ y=0\ \Longleftrightarrow\ x^2-3x+2=0\ \Longleftrightarrow\ x=2\ \texttt{ OR }\ x=1. \end{array}$$ $\square$