##### Tools

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

# Operations on functions

## 1 Operations on sets

Example. Recall the example from last chapter of five boys that form a set and another set is the set of these four balls:

They are lists: $$\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}$$ without repetitions. We can form a new set that contains all the elements of the two sets.

$\square$

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$.

Example. We merge lists together and then carefully remove the “overlap”: $$\{1,2,3,4\}\cup\{3,4,5,6,7\}=\{1,2,3,4,\ 3,4,5,6,7\}=\{1,2,3,4,5,6,7\}.$$ $\square$

Example. We have also subsets of $X$ and $Y$. 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 }\};\\ \{\text{ Tom, Ken }\}\cup \{\text{ basketball, tennis }\}=\{\text{ Tom, Ken, basketball, tennis }\}.\\ \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: $$\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}$$

We can also look for the “overlaps” of these subsets:

$\square$

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$.

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

Example. Numerical sets are subsets of the real line ${\bf R}$. They may consist of just a few separate points:

Recall that these sets came from solving these equations: $$\begin{array}{l|ll} \text{equation }& \text{ solution set }& \text{ simplified }\\ \hline x+2=5 &\{x:\ x+2=5 \}&=\{3\} \\ 3x=15 &\{x:\ 3x=15 \}& =\{5\} \\ x^2-3x+2=0 &\{x:\ x^2-3x+2=0 \} & =\{1,2\} \\ x^2+1=0 &\{x:\ x^2+1=0 \}& = \{\quad\}=\emptyset \\ \end{array}$$ $\square$

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

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\ \}.$$ Sometimes the condition that define the set splits into two conditions, $$Z=\{x:\ \text{ first condition for } x\texttt{ AND } \text{ second condition for } x\}.$$ 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, $$P=\{x:\ \text{ first condition for } x\} \text{ and } Q=\{x:\ \text{ second condition for } x\},$$ one for either condition. We are interested in their intersection: $$Z=P\cap Q=\{x:\ \text{ first condition for } x\} \cap \{x:\ \text{ second condition for } x\}.$$

Example. In particular, when these two conditions are equations, there are two solution sets: $$\begin{array}{llcll} &\{x:\ x^2-3x+2=0 &\texttt{ AND }& x^2=1\}\\ =& \{x:\ x^2-3x+2=0\}&\cap&\{x:\ x^2=1\} \\ =& \{1,2\}&\cap&\{-1,1\}\\ =&\{1\}. \end{array}$$

These conditions can also be inequalities. They produce intervals:

These intervals are presented in the interval notation: $$\begin{array}{lll} \{x:\ x\ge 3 \}&=[3,\infty), \\ \{x:\ 1\le x\le 2 \}& =[1,2], \\ \{x:\ x\le 0 \} & = (-\infty,0], \\ \{x:\ 1\ge x\ge 2 \}& = \emptyset.\\ \end{array}$$ Similarly to the above, 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 4\}\\ =& \{x:\ x\ge 0\}&\cap&\{x:\ x\le 3\} \\ =& (-\infty,3]&\cap &[0,\infty)\\ =&[0,3]. \end{array}$$

$\square$

Example. Furthermore, we now have another “big” set that produces examples of sets as its subsets; it's the Cartesian plane ${\bf R}^2$! For example, we can have a “sequence” of infinitely many points on the plane:

It may not fit on the piece of paper, but they can also trend toward a particular point (as discussed in Chapter 4):

$\square$

Example. All the graphs (of both relations and functions) are subsets of ${\bf R}^2$.

Suppose we have a relation $R$ between $X={\bf R}$ and $Y={\bf R}$. Then, the graph of $R$ is a subset of ${\bf R}^2$ that consists of all points $(x,y)$ that $x$ and $y$ are related via $R$. Just as in the last chapter, we test one point at a time ($x+y=2$):

For a function $F:{\bf R}\to {\bf R}$, its graph is the following set given by 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. Meanwhile, the $y$-intercept of $F$ is the only element of the intersection of the graph of $F$ with the $y$-axis.

$\square$

Example. What if we have two graphs; what is the meaning of their intersection? For example, this is the intersection of the graphs of these two relations: $$x-2y=-2 \text{ and } x+y=2.$$

So, the intersection is a point and this point $(x,y)$ is the solution of the system of equations formed by these two equations: $$\begin{cases} x&-&2y&=2,\\ x&+&y&=2. \end{cases}$$ Just as before, when there are two equations, there are two sets: $$\begin{array}{llcll} &\{(x,y):\ x-2y=2 &\texttt{ AND }&x+y=2\}\\ =& \{(x,y):\ x-2y=2\}&\cap&\{(x,y):\ x+y=2\}\\ =&\{(2,0)\}. \end{array}$$ The intersection is a single point. $\square$

Example. There are more examples of set building on the plane. The regions above and below the graph of a function $y=f(x)$ are given by, respectively: $$\{(x,y):\ y\ge f(x)\} \text{ and }\{(x,y):\ y\le f(x)\}.$$

And this is the disk, i.e., the region inside the circle of radius $R$: $$\{(x,y):\ x^2+y^2\le R^2\} .$$

More examples of these two operations for subsets of the plane:

These may also serve as illustrations of unions and intersections of “generic” sets. $\square$

## 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.

• We define the new function the domain of which is the union of the domains of the two functions.
• 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 $F: A \to Y,\ G:B\to Y$ are functions, and $$F(x)=G(x),\text{ for all } x \text{ in } A\cap B.$$ Then the values of the piece-wise defined function $f:X\to Y$ are given by:

• $f(x)=F(x)$ if $x$ is in $A$,
• $f(x)=G(x)$ if $x$ is in $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}$$

In case of numerical functions, two functions can be “glued together” to create a new function, as follows.

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: $$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,\\ ... &...\quad, \end{cases}$$ provided $A_i\cap A_j=\emptyset$ for $i\ne j$. Just as all algebraic formulas, it is to be read from inside out.

Example. 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]$. We see these three “brackets” as three functions. Now, the values are all different, so we need to make sure that there is no overlap of their domains:

• 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 all past examples, there is a fork on the road this time. Depending on how we answer these questions about $x$, we choose the right route for our computation: $$\begin{array}{cccccc} f(x):& 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 5. 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, so the direction is positive, and we say “$1$”;
• $-5$ is to the left, so the direction is negative, and we say “$-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}{cccccc} 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 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 range is them, $\{-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 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&-3&-2&-1&-.5&0&.5&1&2&3\\ \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”. This issue is discussed in Chapter 5.

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 can 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}{cccccc} 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: $$\operatorname{sign}(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.$$

Example. An alternative method is as follows:

• if $x \le 0$ then $y = - x$; and
• if $x \ge 0$ then $y = x$.

It is produced according to the above definition from these two functions:

• $F(x)=x$ defined on $A=[0,+\infty)$, and
• $G(x)=-x$ defined on $B=(-\infty,0]$.

Since he formulas are different but the domains overlap, we make sure that the value is the same on the intersection (it's $0$ in either case). $\square$

Exercise. Present a flowchart for this definition.

It is clear that the domain of this function is ${\bf R}=(-\infty,+\infty)$. To find the range, 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 range 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}$$

Warning: The graph on the left is the complete graph of the function $f(x)=|x|$ with the domain taken to be the integers.

As we plot more and more of those points, we realize that -- in contrast to $y=\operatorname{sing}(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”. The change of direction is abrupt! This issue is discussed in Chapter 6.

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$.

We always move towards the negative: $$[5]=5,\ [3.1]=[3.99]=3,\ [-4.1]=-5.$$

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.

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 range, 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 range 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”.

Example. Note that -- generally -- the “pieces” of a piece-wise defined function don't have to fit together well:

$\square$

Example. 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. 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 in the black box when we step outside the domain: $$\begin{array}{cccccc} 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}$.


Example. Suppose now I know to multiply. Problem: I have a few $2$-by-$4$s and I need a table $20$ inches wide. How many do I need? Answer: $5$. How do I know? Algebra: solve $$4x = 20 .$$ This equation leads to a new operation, division: $x = \frac{20}{4}$. Division is the “inverse” of multiplication. $\square$

Example. I need a square table of area 25 square feet. What is the width of the table? Algebra: Solve $$x \cdot x = 25 \Longrightarrow x^{2} = 25 \Longrightarrow x = \sqrt{25} .$$ Thus, we have a new operation: square root. It is the “inverse” of square. $\square$

Example. What about $\sqrt[3]{\quad}$? What is the side of a box given a volume of $8$ cubic feet? Solve $$x^{3} = 8 \Longrightarrow x = \sqrt[3]{8}.$$ $\square$

Thus, solving equations requires us to undo some operations present in the equation: $$\begin{array}{rl} x+2=5& \Longrightarrow & (x+2)-2=5-2& \Longrightarrow &x=3;\\ 3x=6&\Longrightarrow & (3x)/3=6/3&\Longrightarrow &x=2;\\ x^2=4&\Longrightarrow & \sqrt{x^2}=\sqrt{4}& \Longrightarrow &x=\pm 2. \end{array}$$

But these are functions! And some functions undo the effect of others:

• the addition of $2$ is undone by the subtraction of $2$, and vice versa;
• the multiplication by $3$ is undone by the division by $3$, and vice versa;
• the second power is undone by the square root (for $x\ge 0$), and vice versa.

Each of these undoes the effect of its counterpart under substitution:

• substituting $y=x+2$ into $x=y-2$ gives us $x=x$;
• substituting $y=3x$ into $x=\frac{1}{3}y$ gives us $x=x$;
• substituting $y=x^2$ into $x=\sqrt{y}$ gives us $x=x$, for $x,y\ge 0$.

And vice versa!

• substituting $x=y-2$ into $y=x+2$ gives us $y=y$;
• substituting $x=\frac{1}{3}y$ into $y=3x$ gives us $y=y$;
• substituting $x=\sqrt{y}$ into $y=x^2$ gives us $y=y$, for $x,y\ge 0$.

As we know, it is more precise to say that they undo each other under composition: two numerical functions $y=f(x)$ and $x=g(y)$ are inverse of each other when for all $x$ in the domain of $f$ and for all $y$ in the domain of $g$, we have: $$g(f(x))=x \quad\text{ and }\quad f(g(y))=y.$$ This is how they are written via substitutions: $$g(y)\Bigg|_{y=f(x)}=x \quad\text{ and }\quad f(x)\Bigg|_{x=g(y)}=y.$$

Thus, we have three pairs of inverse functions: $$\begin{array}{rl} f(x)=x+2& \text{ vs. }& f^{-1}(y)=y-2,\\ f(x)=3x&\text{ vs. }& f^{-1}(y)=\frac{1}{3}y,\\ f(x)=x^2&\text{ vs. }& f^{-1}(y)=\sqrt{y} \quad\text{ for }x,y\ge 0. \end{array}$$

Next, what is the relation between the graph of a function and the graph of its inverse?

In other words, what do we do with the graph of $f$ to get the graph $f^{-1}$? We don't really need to do anything. After all, a function and its inverse represent the same relation. Indeed, the graph of $f$ illustrates how $y$ depends on $x$... as well as how $x$ depends on $y$. But the latter is what determines $f^{-1}$! So, there is no need for a new graph -- the graph of $f^{-1}$ is the graph of $f$. The only problem is that the $x$- and $y$-axes point in the wrong directions. It's easy to fix.

Example (points on the graph). Transitioning from $f$ to its inverse $f^{-1}$, $$f=\begin{array}{l|l} x&y=f(x)\\ \hline 2&5\\ 3&1\\ 8&7\\ ... \end{array}\quad \leadsto \quad f^{-1}=\begin{array}{l|l} y&x=f^{-1}(y)\\ \hline 5&2\\ 1&3\\ 7&8\\ ... \end{array}$$ makes us replace the points in the $xy$-plane to new points $(y,x)$ in the $yx$-plane: $$\begin{array}{ll} (2,5)&\leadsto&(5,2)\\ (3,1)&\leadsto&(1,3)\\ (8,7)&\leadsto&(7,8)\\ ... \end{array}$$ The coordinates are flipped. As a result, each point jumps across the diagonal line, as shown below:

So, every point $(x,y)$ in the $xy$-plane corresponds to the point $(y,x)$ in the $yx$-plane. $\square$

We realize that this is a reflection of the plane with respect to the diagonal line $y=x$, a new transformation of the plane.

Example. This can be done by hand. One grabs the piece of paper with the $xy$-axis and the graph of $y=f(x)$ on it and flips it. We flip by grabbing the end of the $x$-axis with the right hand and grabbing the end of the $y$-axis with the left hand then interchanging them:

We face the opposite side of the paper then, but the graph is still visible: the $x$-axis is now pointing up and the $y$-axis right, as intended. $\square$

Example. We can also fold:

The shapes of the graphs are the same!

$\square$

Example (graph with software). Such a transformation of the plane can be accomplished with image processing software by first rotating the image clockwise $90$ degrees and then flipping it vertically:

Suppose a function is given only by its graph. Find the graph of the inverse $x = f^{-1}(y)$.

$\square$

Example (graph point by point). Suppose, again, a function is given only by its graph and we need to find the graph of the inverse $x = f^{-1}(y)$. This time we are to do this without any help.

Start with choosing a few points on the graph. Each of them will just across the diagonal under this flip. How exactly? The general rule for plotting a counterpart of a point is:

• from the point go perpendicular to the diagonal ($45$ degrees) and then measure the same distance on the other side.

In other words, we plot a line through our point with slope $-1$. However, we can choose the point more judiciously: choose ones with easy to find counterparts. First, points on the diagonal don't mode by the flip about the diagonal. Second, points on one of the axes jumps to the other axis with no need for measuring. Once all points are in place, finally, draw a curve that connects them. $\square$

Furthermore, we only need the graph of the original function to be able to evaluate the inverse:


However, we can make it work by restricting the domain and the codomain of the function. For example, the old function is $y = x^{2}$, with the domain and the codomain assumed to be $(-\infty, \infty)$. It simply doesn't have the inverse! The new function is $y = x^{2}$, with the domain and the codomain chosen to be $[0, \infty )$. Then it works: this function has the inverse:

We have eliminated the second possibility: $$2^{2} = 4,\ (-2)^{2} = 4.$$

So, $f(x)=x^{2}$ is not one-to-one, but $g(x)=x^{3}$ is!

What is the difference? The latter satisfies the Horizontal Line Test: a function is one-to-one if and only if every horizontal line has at most one intersection with its graph.

$\square$

Theorem (Powers). The odd powers are one-to-one; consequently, they are invertible. The even powers aren't one-to-one; consequently, they are not invertible. The even powers with domains and codomains reduced to $[0,+\infty)$ are one-to-one; consequently, they are invertible.

Exercise. Can we reduce the domain to $(-\infty,0]$ instead? Are there other options?

Example. Suppose a function is given only by its formula. Find the formula of the inverse $x = f^{-1}(y)$. For example, let $$f(x)=x^3-3.$$ We simply rewrite $$y=x^3-3,$$ and then solve for $x$: $$x=\sqrt[3]{y+3}.$$ Thus the answer is: $$f^{-1}(y)=\sqrt[3]{y+3}.$$ $\square$

Example. Plot the graph of the inverse of $y = f(x)$ shown below:

• Draw the diagonal $y = x$,
• pick a few points on the graph of $f$ (we choose four);
• plot a corresponding point for each of them:
• on the line through point $A$ that is perpendicular to the diagonal (i.e., its slope is $45$ degrees down),
• on the other side of the diagonal from $A$,
• same distance from the diagonal as $A$;
• draw by hand a curve from point to point;
• verify the answer with drawing software.

$\square$

Exercise. Function $y=f(x)$ is given below by a list its values. Find its inverse and represent it by a similar table. $$\begin{array}{r|l|l|l}x &0 &1 &2 &3 &4 \\\hline y=f(x) &1 &2 &0 &4 &3 \end{array}$$

Exercise. What is the function that is its own inverse?

Exercise. Plot the inverse of the function shown below, if possible.

Exercise. Plot the graph of the inverse of this function:

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

Exercise. Plot the graph of the function $f(x)=\frac{1}{x-1}$ and the graph of its inverse. Identify its important features.

Exercise. Find the formulas of the inverses of the following functions: (a) $f(x)=(x+1)^3$, (b) $g(x)=\ln (x^3)$.

Exercise. Sketch the graph of the inverse of the function below:

## 7 Transforming the axes transforms the plane

First, a function is represented by its graph as a certain subset of the $xy$-plane. Second, a function is seen as a transformation of the real number line. Now, we discover two prominent number lines on the $xy$-plane: the $x$-axis and the $y$-axis! Suppose we have the graph of a function $f$. We then face the following two questions.

• Question 1: What will happen to the graph of $f$ if the $x$-axis is transformed by another function $g$? Answer: the graph will transform into that of $f\circ g$.
• Question 2: What will happen to the graph of $f$ if the $y$-axis is transformed by another function $h$? Answer: the graph will transform into that of $h\circ f$.

The order, of course, matters: $$\begin{array}{ccc} t & \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 \\ &&&&x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad h \quad \\ \hline\end{array} & \mapsto & z \end{array}$$

The graphs of functions are plotted on the Cartesian plane. We then start with a broader question:

• how the transformations of the axes -- both horizontal and vertical -- affect the $xy$-plane?

But first let's review what we know. These are the three transformations of an axis: shift, flip, and stretch:


Now, transforming the axes transforms -- in the same manner -- all the lines on the plane parallel to it. The result is this set of transformations familiar from using a graphics editor:

What remains is to see how the above algebra of the real line creates a new algebra of the Cartesian plane.

We start with a vertical shift. We shift the whole $xy$-plane as if it is printed on a sheet of paper. Furthermore, there is another sheet of paper underneath used for reference. It is on the second sheet that we see the resulting points. We then use its coordinate system to record the coordinates of the new point. For example, a shift of $3$ units upward is shown below:


Exercise. What is the effect of two vertical stretches executed consecutively?

What about the horizontal shift? For example, a shift of $2$ units right is shown below:


Exercise. What is the effect of a vertical stretch and a horizontal stretch executed consecutively? What if we change the order?

These shifts can also be described a translation along the $y$-axis and a translation along the $x$-axis respectively. That is why the former only changes the $y$-coordinates of the points and the latter only the $x$-coordinates.

Now a vertical flip. We lift, then flip the sheet of paper with $xy$-plane on it, and finally place it on top of another such sheet so that the $x$-axes align. This flip is shown below:


Exercise. What is the effect of two vertical flips executed consecutively?

For the horizontal flip, we lift, then flip the sheet of paper with $xy$-plane on it, and finally place it on top of another such sheet so that the $y$-axes align. This flip is shown below:


Exercise. What is the effect of a vertical flip and a horizontal flip executed consecutively? What if we change the order?

These flips can also be described a mirror reflection about the $x$-axis and a mirror reflection about the $y$-axis respectively. That is why the former only changes the $y$-coordinates of the points and the latter only the $x$-coordinates.

Next, a vertical stretch. The coordinate system isn't on a piece of paper anymore! It is on a rubber sheet. We grab it by the top and the bottom and pull them apart in such a way that the $x$-axis doesn't move. For example, a stretch by a factor of $2$ is shown below:


Even though the stretch is the same, the placement will vary depending on the location of the object relative to the $x$-axis:


Exercise. What is the effect of a vertical flip and a horizontal shift executed consecutively? What if we change the order?

What about horizontal stretch? This time, we grab it by the left and right edges of the rubber sheet and pull them apart in such a way that the $y$-axis doesn't move. For example, a stretch by a factor of $2$ is shown below:


Exercise. What is the effect of a vertical flip and a horizontal flip executed consecutively? What if we change the order?

Exercise. What is the effect of a vertical projection and a horizontal projection executed consecutively?

These stretches can also be described a uniform deformation away from the $y$-axis and a uniform deformation away from the $y$-axis respectively. That is why the former only changes the $x$-coordinates of the points and the latter only the $y$-coordinates.

These are our six basic transformations:

The algebra below reflects the geometry above. $$\begin{array}{lcccclcccclcccc}\text{Vertical shift: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x&,&y+k&)\end{array},&\text{flip: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x&,&y\cdot(-1)&)\end{array},&\text{stretch: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x&,&y\cdot k&)\end{array}\\ \text{Horizontal shift: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x+k&,&y&)\end{array},&\text{flip: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x\cdot(-1)&,&y&)\end{array},&\text{stretch: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x\cdot k&,&y&)\end{array}\end{array}.$$ Horizontal transformations don't change $y$ and vertical don't change $x$!

These transformations of the plane are functions of the plane to itself, i.e., $F:{\bf R}^2\to{\bf R}^2$. For now, each of these six operations is limited to one of the two directions: along the $x$-axis or along the $y$-axis. We combine them as compositions. For example, $$\begin{array}{ccc} ...& \to & \begin{array}{|c|}\hline\quad \text{ stretch vertically by }k \quad \\ \hline\end{array} & \to & \to & \to & \begin{array}{|c|}\hline\quad \text{ flip horizontally } \quad \\ \hline\end{array} & \to &... \\ (x,y) & \mapsto & \begin{array}{|c|}\hline\quad \text{ multiply }y\text{ by }k \quad \\ \hline\end{array} & \mapsto & (x,yk) & \mapsto & \begin{array}{|c|}\hline\quad \text{ multiply }x\text{ by }(-1) \quad \\ \hline\end{array} & \mapsto & (-x,yk). \end{array}$$ We produce a variety of results:

Exercise. Execute -- both geometrically and algebraically -- the following transformations:

• translate up by $2$, then reflect about the $x$-axis, then translate left by $3$;
• pull away from the $y$-axis by a factor of $3$, then pull toward the $x$-axis by a factor of $2$.

Exercise. What sequences of transformations produce these results?

Exercise. Describe -- both geometrically and algebraically -- a transformation that makes a circle into an oval.

Exercise. What transformations increase/decrease slopes of lines?

Exercise. Point out the inverses of each of the six transformations of the plane on the list.

Exercise. Has this parabola been shrunk vertically or stretched horizontally?

Recall some of the transformations of the plane we saw in the last chapter when we discussed symmetry. For example, the fact that the parabola's left branch is a mirror image of its right branch is revealed via a horizontal flip: $$(x,y)\mapsto (-x,y).$$

How do we represent a rotation $180$ degrees around the origin?

We can imagine instead we flip the plane about the $y$-axis and then about the $x$-axis (or vice versa): $$(x,y)\mapsto (-x,y)\mapsto (-x,-y).$$ However, some transformations cannot be decomposed into a composition of those six transformations! Here is, for example, a $90$-degree rotation:

Exercise. Find a formula for a $90$-degree clockwise rotation.

Another is a flip about the line $x=y$ that appeared in the last section:

It is given by $$(x,y)\mapsto (y,x).$$ Transformations of the plane are discussed in Chapter 17 and Chapter 22.

Exercise. What are the inverses of the transformations presented in this section?

Before addressing functions, what happens to relations under these transformations? We just execute the corresponding substitution in the formula. For example, what happens to the line $$3x-5y=7$$ under the shift $5$ units left and $2$ units up? We execute the substitution: $$u=x+5,\ v=y+5\,\ \text{ or }\ x=u-5,\ y=v-5.$$ This is the new line: $$3(u-5)-5(v-2)=7.$$ The circle $$x^2+y^2=1$$ becomes $$(u-5)^2+(v-2)^2=1.$$ And so on. Now, a function $$y=f(x)\ \text{ becomes }\ (v-2)=f(u-5).$$ Are we done? Not yet, the formula for the new function is: $$v=f(u-5)+2.$$ This minus sign is something to watch out for when dealing with transformations of functions.

## 8 Changing variables transforms the graphs of functions

We now look at what happens to the graph of a function “drawn” on the $xy$-plane as it is being transformed.

Warning: graphs aren't functions and functions aren't graphs; this is about visualization...

For the six transformations, there will be six rules governing the algebra of the functions affected by them.

We start with the vertical shift. Since the graph is drawn on the same piece of paper, it is shifted exactly the same way.

What about the formula for the new function? Suppose a point $(x,y)$ lies on the graph of $f$, then $f(x)=y$. The shifted point $(x,y+k)$ lies on the graph of the new function $F$, hence $F(x)=y+k=f(x)+k$.

Rule 1 (vertical shift): If the graph $y = F(x)$ is the graph of $y = f(x)$ shifted $k$ units up, then $$F(x) = f(x) + k,$$ and vice versa.

By “vice versa”, we mean that if function $g$ satisfies $F(x) = f(x) + k$ then its graph is the graph of $f$ shifted $k$ units up.

The most important conclusion is the new function has the exact same shape of the graph as the old one.

Next is the horizontal shift.

What about the formula for the new function? Things are a bit more complicated than for a horizontal shift. Suppose a point $(x,y)$ lies on the graph of $f$, then $f(x)=y$. The shifted point $(x+k,y)$ lies on the graph of the new function $F$, hence $F(x+k)=y=f(x)$. Therefore, the new function is $F(x)=f(x-k)$.

Example. To confirm the idea, take $f(x) = x^{2}$, and shift $2$ units to the left and to the right too: $$f(x+2) = (x+2)^{2} \text{ and } f(x-2) = (x-2)^{2}.$$

To confirm the match, what is the $x$-intercept of these two new functions? Set either equal to $0$ and solve: $$\begin{array}{r | l} (x + 2) ^2 = 0 & (x - 2) ^2 = 0 \\ x + 2 = 0 & x - 2=0 \\ x = -2 & x = 2\\ \text{left shift } & \text{ right shift } \end{array}$$ The shift is in the opposite direction! $\square$

Rule 2 (horizontal shift): If the graph of $y = F(x)$ is the graph of $y = f(x)$ shifted $k$ units to the right, then $$F(x) = f(x-k),$$ and vice versa.

Once again, the new function has the exact same shape of the graph as the old one.


What about “combination” of these two types of transformations?


$\square$

Exercise. What happens to the $x$- and $y$-intercepts of a function under vertical and horizontal shifts?

Exercise. What happens to the domain and the range of a function under vertical and horizontal shifts?

Next is the vertical flip.

Suppose a point $(x,y)$ lies on the graph of $f$, then $f(x)=y$. The vertically flipped point $(x,-y)$ lies on the graph of the new function $F$, hence $F(x)=-y=-f(x)$.

Rule 3 (vertical flip): If the graph of $y = F(x)$ is the graph of $y = f(x)$ flipped vertically then $$F(x) = - f(x),$$ and vice versa.

Again, the new function has the exact same shape of the graph as the old one.

Example. Let $$Q(x) = - f(x) + 3.$$ How do we get the graph of $h$? $$x \longmapsto f(x) \underbrace{\longmapsto}_{\textrm{vertical flip}} - f(x) \underbrace{\longmapsto}_{\textrm{vertical shift}} - f(x) + 3.$$ The order matters... Let's interchange these two: $$x \longmapsto f(x) \underbrace{\longmapsto}_{\textrm{vertical shift}} f(x) + 3 \underbrace{\longmapsto}_{\textrm{vertical flip}} - (f(x)+3).$$ The graphs are also different:

$\square$

Next is the horizontal flip.

Suppose a point $(x,y)$ lies on the graph of $f$, then $f(x)=y$. The horizontally flipped point $(-x,y)$ lies on the graph of the new function $F$, hence $F(-x)=y=f(x)$. Therefore, $F(x)=-f(x)$.

Rule 4 (horizontal flip): If the graph of $y = F(x)$ is the graph of $y = f(x)$ flipped horizontally, then $$F(x) = f(-x),$$ and vice versa.

Exercise. Does the order matter when the horizontal flip is combined with a horizontal shift? What about the horizontal flip with a vertical shift?


Exercise. What happens to the $x$- and $y$-intercepts of a function under vertical and horizontal flips?

Exercise. What happens to the domain and the range of a function under vertical and horizontal flips?

Next is the vertical stretch.

Suppose a point $(x,y)$ lies on the graph of $f$, then $f(x)=y$. After a vertical stretch, the point $(x,ky)$ lies on the graph of the new function $F$, hence $F(x)=ky=kf(x)$.

Rule 5 (vertical stretch): If the graph of $y = F(x)$ is the graph of $y = f(x)$ stretched vertically by a factor of $k > 0$, then $$F(x) = kf(x),$$ and vice versa.

Next is the horizontal stretch.

What about the formula for the new function after the plane has been stretched, horizontally? Suppose a point $(x,y)$ lies on the graph of $f$, then $f(x)=y$. After the stretch, the point $(kx,k)$ lies on the graph of the new function $F$, hence $F(kx)=y=f(x)$. Therefore, $F(x)=f(x/k)$.

Rule 6 (horizontal stretch): If graph $y = F(x)$ is the graph of $y = f(x)$ stretched by the factor $k>0$ horizontally, then $$F(x) = f(x/k),$$ and vice versa.

It is clear that the new function has a somewhat different shape of the graph than the old one.

Example. One can stretch and shrink with image processing software:

$\square$


Example. It seems that vertical stretching is somehow equivalent to horizontal shrinking. Consider $$f(x) = x.$$ Stretched by a factor $2$ vertically it becomes: $$F(x) = 2 x.$$ Shrunk by a factor $2$ horizontally it becomes: $$Q(x) = x/\tfrac{1}{2}=2x.$$ It is the same function. However, if we do the same to $f(x)=x^2$, we discover that $$2 x^{2} \ne (2 x )^{2}!$$ Let's try the horizontal stretch by $\sqrt{2}$. Then $$H(x) = (\sqrt{2} x )^{2}.$$ Now there is a match: $$(\sqrt{2} x)^{2} =2 x^{2}.$$ We don't expect such a match for most functions; just try $f(x)=1$! $\square$

This is the summary of our general analysis: the vertical transformations of the graph of a function $y=f(x)$ result from compositions of $f$ with functions that follow $f$, i.e., $h\circ f$:

And the horizontal transformations result from compositions of $f$ with functions that precede $f$, i.e., $f\circ g$:

As we can see, such a transformation of an axis is a change of variables (or units). Every function $f$ has two, input and output. Then,

• in the former case, we change the output variable: from $y$ to $z=h(y)$, while
• in the latter case, we change the input variable: from $x$ to $t=g^{-1}(x)$.

This difference is the reason why the effect on the graph of $f$ is so different.

Exercise. What happens to the $x$- and $y$-intercepts of a function under vertical and horizontal stretches?

Exercise. What happens to the domain and the range of a function under vertical and horizontal stretches?

Exercise. (a) How do these transformations affect the monotonicity of a function? (b) Investigate the monotonicity of quadratic functions.

Exercise. By transforming the graph of $y=x^2$, plot the graphs of the functions: (a) $y=\sqrt{x}$ and (b) $y=\sqrt{x+3}$.

## 9 The graph of a quadratic polynomial is a parabola

In this section, we will concentrate on a specific class of functions.

We have called the graph of $y=x^2$ a “parabola”. What about others?

$$\begin{array}{|c|}\hline \\ \quad \text{ The graph of every quadratic polynomial is a parabola.} \quad \\ \\ \hline\end{array}$$

This is what it means. Suppose we have a quadratic polynomial, $$F(x)=ax^2+bx+c,\ a\ne 0,$$ then its graph can be acquired from the parabola of $$f(x)=x^2,$$ via our six transformations, even fewer in fact.

Example (transforming a parabola). Suppose the graph of $g$ is given on right. We need to transform the graph of $y=x^2$ into this parabola.

• The most obvious feature is that the right one opens down. We will, therefore, have to do a vertical flip.
• The second most prominent feature is that the right one is slimmer. We will have do a vertical stretch or a horizontal shrink.
• The last one is the location: the vertex of the parabola is away from the origin. We will have to do both vertical and horizontal shifts.

Note that a horizontal flip is useless here because the parabola has a vertical mirror symmetry. Also note that we pick a vertical stretch over a horizontal shrink as a simpler one to implement.

We now turn to the actual algebra. What is the order of operations? We start with the vertical: $$\begin{array}{rcl} \text{original:}& x^2\\ \text{vertical flip:}& x^2\cdot (-1)&=-x^2\\ \text{vertical stretch:}& x^2\cdot (-1)\cdot 5&=-5x^2\\ \text{vertical shift:}& x^2\cdot (-1)\cdot 5+4&=-5x^2+4\\ \text{horizontal shift:}& (x-3)^2\cdot (-1)\cdot 5+4&=-5(x-3)^2+4\\ \end{array}$$ This algebra produces the following sequence of transformations:

One can also see how the data is changing as we progress through the sequence:

$\square$

If the polynomial is given by a formula, its standard representation, $$f(x)=ax^2+bx+c,\ a\ne 0,$$ the list of such transformations is unclear. Judging by the example, we need to morph it into the following form: $$f(x)=a(x-h)^2+k.$$ While $a$ contains information about the stretch/shrink and the flip of the graph, $h$ and $k$ are the shifts. In fact, the point $(h,k)$ is called the vertex of the parabola.

Example (completing a square). Let's show how this is done algebraically. Suppose $$f(x)=2x^2+8x+3.$$ We manipulate the formula towards our goal: $$\begin{array}{ll} f(x)&=2x^2+8x+3&\text{ start with the original;}\\ &=(2x^2+8x)+3&\text{ bring together the two terms with }x;\\ &=2(x^2+4x)+3&\text{ factor, so that you have }x^2;\\ &=2(x^2+4x+2^2-2^2)+3&\text{ add (and subtract) the missing term of the square;}\\ &=2(x^2+4x+2^2)-2\cdot 2^2+3&\text{ pull out the extra term;}\\ &=2(x+2)^2-8+3&\text{ complete the square;}\\ &=2(x+2)^2-5&\text{ acquire the final form.}\\ \end{array}$$ Reading from the inside out: shift left by $2$, stretch vertically by $2$, flip vertically, shift up by $15$.

$\square$

Exercise. How can you transform any parabola into any other parabola?

Recall the complete square formula: $$(u+v)^2=u^2+2uv+v^2.$$ A quadratic polynomial that may be called a “complete square” if it is $$f(x)=(x-h)^2=x^2+2xh+h^2.$$ It is easy to plot; just shift the original $h$ units right. This idea has a broader applicability, but the challenge is to recognize complete squares in (or extract from) quadratic polynomials.

Theorem. Any quadratic function $$f(x)=ax^2+bx+c,\ a\ne 0,$$ can be represented as an “incomplete square”: $$f(x)=a(x-h)^2+k,$$ where $h,k$ are for some numbers.

Proof. All we need is to find these parameters: $h$ and $k$. We simply set the two equal to each other: $$f(x)=ax^2+bx+c=a(x-h)^2+k=ax^2+2axh+ah^2+k.$$ We then match up the terms: $$b=2ah,\ c=ah^2+k.$$ Then, $$h=-\frac{b}{2a},\ k=c-ah^2.$$ $\blacksquare$

Consequently, the graph of $f$ can be acquired from the graph of $y=x^2$ via the six transformations, or just four if we exclude the vertical flip and the horizontal shrink. We can say that there is only one parabola!

Exercise. The graphs below are parabolas. One is $y=x^2$. What is the other?

In conclusion, composing a function with a linear function -- before or after -- will transform its graph in these six ways: shift, flip, and stretch, vertical or horizontal. This is the summary of the rules: $$\begin{array}{l|ll||ll} &\text{vertical, }y&&\text{horizontal, }x&\\ \hline \text{shift by }s:&y=f(x)&+s&y=f(x&-s)\\ \text{flip }:&y=f(x)&\cdot(-1)&y=f(x&\cdot(-1))\\ \text{stretch by }k:&y=f(x)&\cdot k&y=f(x&/k)\\ \end{array}$$ What is behind these pairs of transformations we see above? Compare these:

• add $s$ vs. subtract $s$;
• multiply by $(-1)$ vs. multiply by $(-1)$;
• multiply by $k>0$ vs. divide by $k$.

They are inverses of each other. Inverses appeared every time we solved an equation to find the formula for the new function, $F$, after a change of the input variable (i.e., a horizontal transformation) of a function $f$. For example, if we have $F(x+k)=f(x)$ after a horizontal shift, we substitute $u=x+k$ and find $x$ in terms of $u$, i.e., $x=u-k$, resulting in $F(u)=f(u-k)$. After an optional renaming, $u$ for $x$, the formula takes its final form, $F(x)=f(x-k)$.

Exercise. The graph drawn with a solid line is $y=x^3$. What are the other two?

Exercise. The graph below is the graph of the function $f(x)=A\sin x+B$ for some $A$ and $B$. Find these numbers.

Exercise. The graph of the function $y=f(x)$ is given below. Sketch the graph of $y=2f(x)$ and then $y=2f(x)-1$.

## 10 The algebra of compositions

Functions can be visualized as flowcharts and so can be their compositions:


As we see, with the variables properly named, composition is substitution, Indeed,

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

$$u=h(z)=h(g(y)), \quad u=z^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=g(y)=g(f(x)), \quad z=y\cdot 2=(x+3)\cdot 2.$$



Warning: If the names of the variables don't match, it might be for a good reason. In that case, do nothing.

This is what we have after renaming: $$\begin{array}{ccccccccccccccc} & 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}$$ Then we have a diagram of a new function: $$\begin{array}{ccccccccccccccc} g\circ f:& x & \mapsto & \begin{array}{|c|}\hline 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 \\ \hline\end{array} & \mapsto & z \end{array}$$ It's just another black box: $$\begin{array}{ccccccccccccccc} & x & \mapsto & \begin{array}{|c|}\hline \quad g\circ f \quad \\ \hline\end{array} & \mapsto & z \end{array}$$

Compositions are meant to represent tasks that cannot be carried out in parallel. If you have two persons working for you, you can't split the work in half to have them work on it at the same time as the second task cannot be started until the first is finished.

Example. For example, you are making a chair. The last two stages are polishing and painting. You can't do them at the same time: $$\begin{array}{ccccccccccccccc} & \text{ chair } & \mapsto & \begin{array}{|c|}\hline\quad \text{ polishing } \quad \\ \hline\end{array} & \mapsto & & \mapsto & \begin{array}{|c|}\hline\quad \text{ painting } \quad \\ \hline\end{array} & \mapsto & \text{ finished chair } \end{array}$$ You can't change the order either! $\square$

Example. Below the instructions of the function is “push these buttons” (in that order):

These are the functions: $$\frac{1}{x^2},\ \sqrt{x+6},\ -\left( x^2 \right)^2.$$ $\square$

Example. The composition of $$g(x)=x^2 \text{ and } f(x)=x+2$$ is in fact the composition of $$z=g(y)=y^2 \text{ and } y=f(x)=x+2,$$ after renaming. Then we just substitute the latter into the former: $$(g\circ f)(x)=g(f(x))=g(x+2)=(x+2)^2.$$ $\square$

Just as with the rest of the algebraic operations, we sometimes want to “reverse” composition. By doing so, we decompose the given function into two (or more) simpler parts that can then be addressed separately.

Example. Represent $z = h(x) = \sqrt[3]{x^{2} + 1 }$ as the composition of two functions: $$x \mapsto y=x^{2} + 1 \mapsto z=\sqrt[3]{y} .$$ To confirm, substitute back... $\square$

Example. Decompose: $$y=\sin(t^2+1).$$ The presence of parentheses is a clue that what's inside may be our new variable: $$x=t^2+1.$$ We substitute that into the original: $$y=\sin(x).$$ Done! For completeness, we can name the functions: $$x=f(t)=t^2+1,\ y=g(x)=\sin x\ \Longrightarrow\ h(t)=(g\circ f)(t)=\sin(t^2+1).$$ $\square$

Example. Decompose: $$y=\frac{t^2+1}{t^2-1}.$$ There are no parentheses to use as a clue here but what if we choose the numerator (the same formula as in the last example) as our new variable: $$x=t^2+1.$$ We substitute that into the original: $$y=\frac{x}{t^2-1}.$$ Not done! The substitution remains unfinished because there is still $t$ left. Solving a simple equation, we conclude: $$t^2-1=x-2.$$ Then, $$y=\frac{x}{x-2}.$$ Now we are done.

Just as valid, but simpler, choice is $$x=t^2;$$ then $$y=\frac{x+1}{x-1}.$$

What can we say about the choice $$x=\frac{t^2+1}{t^2-1}?$$ The new function is the same as the original. Such a decomposition is, though technically correct, is pointless as it provides no simplification. $\square$

Exercise. Decompose $y=\frac{1}{t^2+1}.$

There may be more than two functions involved in compositions.


Note: the implied domains of these new functions are to be determined.

These are two important groups of functions.

Theorem. (a) The sum, the difference, or the product of two polynomials is also a polynomial. (b) The sum, the difference, the product, or the quotient of two rational functions is also a rational function.

Exercise. Explain the difference between these two functions: $$\sqrt{\frac{x-1}{x+1}}\text{ and } \frac{\sqrt{x-1}}{\sqrt{x+1}}.$$

All four algebraic operations produce new functions in the same manner: $$\begin{array}{ccccccccccccccc} x & \mapsto & \begin{array}{|c|}\hline &x& \begin{array}{lllll} \nearrow &x &\mapsto &\begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y & \searrow\\ \\ \searrow &x &\mapsto &\begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & u & \nearrow\\ \end{array}& \begin{array}{|c|}\hline\quad +\ -\ \cdot\ \div \quad \\ \hline\end{array} \mapsto & z \\ \hline \end{array} & \mapsto & z \end{array}$$