## Combine vertical and horizontal shifts

Now that we have two transformations, we can combine them together. Vertical shifts are outside changes that affect the output ( $y\text{-}$ ) axis values and shift the function up or down. Horizontal shifts are inside changes that affect the input ( $x\text{-}$ ) axis values and shift the function left or right. Combining the two types of shifts will cause the graph of a function to shift up or down and right or left.

### How To: Given a function and both a vertical and a horizontal shift, sketch the graph.

1. Identify the vertical and horizontal shifts from the formula.
2. The vertical shift results from a constant added to the output. Move the graph up for a positive constant and down for a negative constant.
3. The horizontal shift results from a constant added to the input. Move the graph left for a positive constant and right for a negative constant.
4. Apply the shifts to the graph in either order.

### Example 16: Graphing Combined Vertical and Horizontal Shifts

Given $f\left(x\right)=|x|$, sketch a graph of $h\left(x\right)=f\left(x+1\right)-3$.

The function $f$ is our toolkit absolute value function. We know that this graph has a V shape, with the point at the origin. The graph of $h$ has transformed $f$ in two ways: $f\left(x+1\right)$ is a change on the inside of the function, giving a horizontal shift left by 1, and the subtraction by 3 in $f\left(x+1\right)-3$ is a change to the outside of the function, giving a vertical shift down by 3. The transformation of the graph is illustrated in Figure 22.

Let us follow one point of the graph of $f\left(x\right)=|x|$.

• The point $\left(0,0\right)$ is transformed first by shifting left 1 unit: $\left(0,0\right)\to \left(-1,0\right)$
• The point $\left(-1,0\right)$ is transformed next by shifting down 3 units: $\left(-1,0\right)\to \left(-1,-3\right)$

Figure 23 is the graph of $h$.

Figure 23

### Try It 8

Given $f\left(x\right)=|x|$, sketch a graph of $h\left(x\right)=f\left(x - 2\right)+4$.

Solution

### Example 17: Identifying Combined Vertical and Horizontal Shifts

Write a formula for the graph shown in Figure 24, which is a transformation of the toolkit square root function.

Figure 24

### Solution

The graph of the toolkit function starts at the origin, so this graph has been shifted 1 to the right and up 2. In function notation, we could write that as

$h\left(x\right)=f\left(x - 1\right)+2$

Using the formula for the square root function, we can write

$h\left(x\right)=\sqrt{x - 1}+2$

### Analysis of the Solution

Note that this transformation has changed the domain and range of the function. This new graph has domain $\left[1,\infty \right)$ and range $\left[2,\infty \right)$.

### Try It 9

Write a formula for a transformation of the toolkit reciprocal function $f\left(x\right)=\frac{1}{x}$ that shifts the function’s graph one unit to the right and one unit up.

Solution

### Example 18: Applying a Learning Model Equation

A common model for learning has an equation similar to $k\left(t\right)=-{2}^{-t}+1$, where $k$ is the percentage of mastery that can be achieved after $t$ practice sessions. This is a transformation of the function $f\left(t\right)={2}^{t}$ shown in Figure 25. Sketch a graph of $k\left(t\right)$.

Figure 25

### Solution

This equation combines three transformations into one equation.

• A horizontal reflection: $f\left(-t\right)={2}^{-t}$
• A vertical reflection: $-f\left(-t\right)=-{2}^{-t}$
• A vertical shift: $-f\left(-t\right)+1=-{2}^{-t}+1$

We can sketch a graph by applying these transformations one at a time to the original function. Let us follow two points through each of the three transformations. We will choose the points (0, 1) and (1, 2).

1. First, we apply a horizontal reflection: (0, 1) (–1, 2).
2. Then, we apply a vertical reflection: (0, −1) (1, –2).
3. Finally, we apply a vertical shift: (0, 0) (1, 1).

This means that the original points, (0,1) and (1,2) become (0,0) and (1,1) after we apply the transformations.

In Figure 26, the first graph results from a horizontal reflection. The second results from a vertical reflection. The third results from a vertical shift up 1 unit.

Figure 26

### Analysis of the Solution

As a model for learning, this function would be limited to a domain of $t\ge 0$, with corresponding range $\left[0,1\right)$.

### Try It 10

Given the toolkit function $f\left(x\right)={x}^{2}$, graph $g\left(x\right)=-f\left(x\right)$ and $h\left(x\right)=f\left(-x\right)$. Take note of any surprising behavior for these functions.

Solution

## Performing a Sequence of Transformations

When combining transformations, it is very important to consider the order of the transformations. For example, vertically shifting by 3 and then vertically stretching by 2 does not create the same graph as vertically stretching by 2 and then vertically shifting by 3, because when we shift first, both the original function and the shift get stretched, while only the original function gets stretched when we stretch first.

When we see an expression such as $2f\left(x\right)+3$, which transformation should we start with? The answer here follows nicely from the order of operations. Given the output value of $f\left(x\right)$, we first multiply by 2, causing the vertical stretch, and then add 3, causing the vertical shift. In other words, multiplication before addition.

Horizontal transformations are a little trickier to think about. When we write $g\left(x\right)=f\left(2x+3\right)$, for example, we have to think about how the inputs to the function $g$ relate to the inputs to the function $f$. Suppose we know $f\left(7\right)=12$. What input to $g$ would produce that output? In other words, what value of $x$ will allow $g\left(x\right)=f\left(2x+3\right)=12?$ We would need $2x+3=7$. To solve for $x$, we would first subtract 3, resulting in a horizontal shift, and then divide by 2, causing a horizontal compression.

This format ends up being very difficult to work with, because it is usually much easier to horizontally stretch a graph before shifting. We can work around this by factoring inside the function.

$f\left(bx+p\right)=f\left(b\left(x+\frac{p}{b}\right)\right)$

Let’s work through an example.

$f\left(x\right)={\left(2x+4\right)}^{2}$

We can factor out a 2.

$f\left(x\right)={\left(2\left(x+2\right)\right)}^{2}$

Now we can more clearly observe a horizontal shift to the left 2 units and a horizontal compression. Factoring in this way allows us to horizontally stretch first and then shift horizontally.

### A General Note: Combining Transformations

When combining vertical transformations written in the form $af\left(x\right)+k$, first vertically stretch by $a$ and then vertically shift by $k$.

When combining horizontal transformations written in the form $f\left(bx+h\right)$, first horizontally shift by $h$ and then horizontally stretch by $\frac{1}{b}$.

When combining horizontal transformations written in the form $f\left(b\left(x+h\right)\right)$, first horizontally stretch by $\frac{1}{b}$ and then horizontally shift by $h$.

Horizontal and vertical transformations are independent. It does not matter whether horizontal or vertical transformations are performed first.

### Example 19: Finding a Triple Transformation of a Tabular Function

Given the table below for the function $f\left(x\right)$, create a table of values for the function $g\left(x\right)=2f\left(3x\right)+1$.

 $x$ 6 12 18 24 $f\left(x\right)$ 10 14 15 17

### Solution

There are three steps to this transformation, and we will work from the inside out. Starting with the horizontal transformations, $f\left(3x\right)$ is a horizontal compression by $\frac{1}{3}$, which means we multiply each $x\text{-}$ value by $\frac{1}{3}$.

 $x$ 2 4 6 8 $f\left(3x\right)$ 10 14 15 17

Looking now to the vertical transformations, we start with the vertical stretch, which will multiply the output values by 2. We apply this to the previous transformation.

 $x$ 2 4 6 8 $2f\left(3x\right)$ 20 28 30 34

Finally, we can apply the vertical shift, which will add 1 to all the output values.

 $x$ 2 4 6 8 $g\left(x\right)=2f\left(3x\right)+1$ 21 29 31 35

### Example 20: Finding a Triple Transformation of a Graph

Use the graph of $f\left(x\right)$ to sketch a graph of $k\left(x\right)=f\left(\frac{1}{2}x+1\right)-3$.

Figure 27

### Solution

To simplify, let’s start by factoring out the inside of the function.

$f\left(\frac{1}{2}x+1\right)-3=f\left(\frac{1}{2}\left(x+2\right)\right)-3$

By factoring the inside, we can first horizontally stretch by 2, as indicated by the $\frac{1}{2}$ on the inside of the function. Remember that twice the size of 0 is still 0, so the point (0,2) remains at (0,2) while the point (2,0) will stretch to (4,0).

Figure 28

Next, we horizontally shift left by 2 units, as indicated by $x+2$.

Figure 29

Last, we vertically shift down by 3 to complete our sketch, as indicated by the $-3$ on the outside of the function.

Figure 30