# 3.2 Graphing Functions Using Vertical and Horizontal Shifts

Often when given a problem, we try to model the scenario using mathematics in the form of words, tables, graphs, and equations. One method we can employ is to adapt the basic graphs of the toolkit functions to build new models for a given scenario. There are systematic ways to alter functions to construct appropriate models for the problems we are trying to solve.

## Identifying Vertical Shifts

One simple kind of transformation involves shifting the entire graph of a function up, down, right, or left. The simplest shift is a **vertical shift**, moving the graph up or down, because this transformation involves adding a positive or negative constant to the function. In other words, we add the same constant to the output value of the function regardless of the input. For a function [latex]\text{}g\left(x\right)=f\left(x\right)+k,\text{}[/latex] the function [latex]\text{}f\left(x\right)\text{}[/latex] is shifted vertically [latex]\text{}k\text{}[/latex] units. See Figure 3-2 for an example.

To help you visualize the concept of a vertical shift, consider that [latex]\text{}y=f\left(x\right)\text{}[/latex]. Therefore, [latex]\text{}f\left(x\right)+k\text{}[/latex] is equivalent to [latex]\text{}y+k\text{}[/latex]. Every unit of [latex]\text{}y\text{}[/latex] is replaced by [latex]\text{}y+k,\text{}[/latex] so the [latex]\text{}y\text{-}[/latex] value increases or decreases depending on the value of [latex]\text{}k\text{}[/latex]. The result is a shift upward or downward.

**Vertical Shift**

Given a function [latex]f\left(x\right)[/latex], a new function [latex]g\left(x\right)=f\left(x\right)+k[/latex], where [latex]\text{}k[/latex] is a constant, is a vertical shift of the function [latex]f\left(x\right)[/latex]. All the output values change by [latex]k[/latex] units. If [latex]k[/latex] is positive, the graph will shift up. If [latex]k[/latex] is negative, the graph will shift down.

**Example 1: Adding a Constant to a Function**

To regulate temperature in a green building, airflow vents near the roof open and close throughout the day. Figure 3-3 shows the area of open vents [latex]\text{}V\text{}[/latex] (in square feet) throughout the day in hours after midnight, [latex]\text{}t\text{}[/latex]. During the summer, the facilities manager decides to try to better regulate temperature by increasing the amount of open vents by 20 square feet throughout the day and night. Sketch a graph of this new function.

**How To**

**Given a tabular function, create a new row to represent a vertical shift.**

- Identify the output row or column.
- Determine the magnitude of the shift.
- Add the shift to the value in each output cell. Add a positive value for up or a negative value for down.

**Example 2: Shifting a Tabular Function Vertically**

A function [latex]\text{}f\left(x\right)\text{}[/latex] is given in Table 1. Create a table for the function [latex]\text{}g\left(x\right)=f\left(x\right)-3[/latex].

[latex]x[/latex] |
2 | 4 | 6 | 8 |

[latex]f\left(x\right)[/latex] |
1 | 3 | 7 | 11 |

#### Analysis

As with the earlier vertical shift, notice the input values stay the same and only the output values change.

**Example 3: Vertical Shift**

The function [latex]\text{}h\left(t\right)=-4.9{t}^{2}+30t\text{}[/latex] gives the height [latex]\text{}h\text{}[/latex] of a ball (in meters) thrown upward from the ground after [latex]\text{}t\text{}[/latex] seconds. Suppose the ball was instead thrown from the top of a 10-m building. Relate this new height function [latex]\text{}b\left(t\right)\text{}[/latex] to [latex]\text{}h\left(t\right)\text{}[/latex], and then find a formula for [latex]\text{}b\left(t\right)[/latex].

## Identifying Horizontal Shifts

We just saw that the vertical shift is a change to the output, or outside, of the function. We will now look at how changes to input, on the inside of the function, change its graph and meaning. A shift to the input results in a movement of the graph of the function left or right in what is known as a **horizontal shift**, shown in Figure 3-4.

For example, if [latex]\text{}f\left(x\right)={x}^{2}\text{}[/latex], then [latex]\text{}g\left(x\right)={\left(x-2\right)}^{2}\text{}[/latex] is a new function. Each input is reduced by 2 prior to squaring the function. The result is that the graph is shifted 2 units to the right, because we would need to increase the prior input by 2 units to yield the same output value as given in [latex]\text{}f[/latex].

**Horizontal Shift**

Given a function [latex]\text{}f\text{}[/latex], a new function [latex]\text{}g\left(x\right)=f\left(x-h\right)\text{}[/latex], where [latex]\text{}h\text{}[/latex] is a constant, is a horizontal shift of the function [latex]\text{}f\text{}[/latex]. If [latex]\text{}h\text{}[/latex] is positive, the graph will shift right. If [latex]\text{}h\text{}[/latex] is negative, the graph will shift left.

**Example 4: Adding a Constant to an Input**

Returning to our building airflow example from Example 1 (Figure 3-5 below), suppose that in autumn the facilities manager decides that the original venting plan starts too late, and wants to begin the entire venting program 2 hours earlier. Sketch a graph of the new function.

#### Analysis

Note that [latex]\text{}V\left(t+2\right)\text{}[/latex] has the effect of shifting the graph to the *left*.

Horizontal changes or “inside changes” affect the domain of a function (the input) instead of the range and often seem counterintuitive. The new function [latex]\text{}F\left(t\right)\text{}[/latex] uses the same outputs as [latex]\text{}V\left(t\right)\text{}[/latex], but matches those outputs to inputs 2 hours earlier than those of [latex]\text{}V\left(t\right)\text{}[/latex]. Said another way, we must add 2 hours to the input of [latex]\text{}V\text{}[/latex] to find the corresponding output for [latex]F:F\left(t\right)=V\left(t+2\right)[/latex].

**How To**

**Given a tabular function, create a new row to represent a horizontal shift.**

- Identify the input row or column.
- Determine the magnitude of the shift.
- Add the shift to the value in each input cell.

**Example 5: Shifting a Tabular Function Horizontally**

A function [latex]\text{}f\left(x\right)\text{}[/latex] is given in Table 2. Create a table for the function [latex]\text{}g\left(x\right)=f\left(x-3\right)[/latex].

[latex]x[/latex] |
2 | 4 | 6 | 8 |

[latex]f\left(x\right)[/latex] |
1 | 3 | 7 | 11 |

#### Analysis

Figure 3-6 represents both of the functions. We can see the horizontal shift in each point.

**Example 6: Identifying a Horizontal Shift of a Toolkit Function**

Figure 3-7 represents a transformation of the toolkit function [latex]\text{}f\left(x\right)={x}^{2}\text{}[/latex]. Relate this new function [latex]\text{}g\left(x\right)\text{}[/latex] to [latex]\text{}f\left(x\right)\text{}[/latex], and then find a formula for [latex]\text{}g\left(x\right)[/latex].

#### Analysis

To determine whether the shift is [latex]\text{}+2\text{}[/latex] or [latex]\text{}-2[/latex], consider a single reference point on the graph. For a quadratic, looking at the vertex point is convenient. In the original function, [latex]\text{}f\left(0\right)=0\text{}[/latex]. In our shifted function, [latex]\text{}g\left(2\right)=0\text{}[/latex]. To obtain the output value of 0 from the function [latex]\text{}f\text{}[/latex], we need to decide whether a plus or a minus sign will work to satisfy [latex]\text{}g\left(2\right)=f\left(x-2\right)=f\left(0\right)=0\text{}[/latex]. For this to work, we will need to *subtract* 2 units from our input values.

**Example 7: Interpreting Horizontal versus Vertical Shifts**

- The function [latex]\text{}G\left(m\right)\text{}[/latex] gives the number of gallons of gas required to drive [latex]\text{}m\text{}[/latex] miles. Interpret [latex]\text{}G\left(m\right)+10\text{}[/latex] and [latex]\text{}G\left(m+10\right)[/latex].
- Given the function [latex]\text{}f\left(x\right)=\sqrt{x}\text{}[/latex], graph the original function [latex]\text{}f\left(x\right)\text{}[/latex] and the transformation [latex]\text{}g\left(x\right)=f\left(x+2\right)\text{}[/latex] on the same axes. Is this a horizontal or a vertical shift? Which way is the graph shifted and by how many units?

## Combining Vertical and Horizontal Shifts

Now that we have two transformations, we can combine them together. Vertical shifts are outside changes that affect the output [latex](y\text{-})[/latex] axis values and shift the function up or down. Horizontal shifts are inside changes that affect the input [latex](x\text{-})[/latex] 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.**

- Identify the vertical and horizontal shifts from the formula.
- 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.
- 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.
- Apply the shifts to the graph in either order.

**Exercise 8: Graphing Combined Vertical and Horizontal Shifts**

- Given [latex]\text{}f\left(x\right)=|x|\text{}[/latex], sketch a graph of [latex]\text{}h\left(x\right)=f\left(x+1\right)-3[/latex].
- Given [latex]\text{}f\left(x\right)=|x|\text{}[/latex], sketch a graph of [latex]\text{}h\left(x\right)=f\left(x-2\right)+4[/latex].

**Example 9: Identifying Combined Vertical and Horizontal Shifts**

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

#### Analysis

Note that this transformation has changed the domain and range of the function. This new graph has domain [latex]\text{}\left[1,\infty \right)\text{}[/latex] and range [latex]\text{}\left[2,\infty \right)[/latex].

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

Access for free at https://openstax.org/books/precalculus/pages/1-introduction-to-functions