# Graph 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]g\left(x\right)=f\left(x\right)+k\\[/latex], the function [latex]f\left(x\right)\\[/latex] is shifted vertically [latex]k\\[/latex] units.

**Figure 2.** Vertical shift by [latex]k=1\\[/latex] of the cube root function [latex]f\left(x\right)=\sqrt[3]{x}\\[/latex].

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

### A General Note: 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]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 2 shows the area of open vents [latex]V[/latex] (in square feet) throughout the day in hours after midnight, [latex]t[/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.**Figure 3**

### Solution

We can sketch a graph of this new function by adding 20 to each of the output values of the original function. This will have the effect of shifting the graph vertically up, as shown in Figure 4.**Figure 4**

Notice that for each input value, the output value has increased by 20, so if we call the new function [latex]S\left(t\right)[/latex], we could write

This notation tells us that, for any value of [latex]t,S\left(t\right)\\[/latex] can be found by evaluating the function [latex]V[/latex] at the same input and then adding 20 to the result. This defines [latex]S[/latex] as a transformation of the function [latex]V[/latex], in this case a vertical shift up 20 units. Notice that, with a vertical shift, the input values stay the same and only the output values change.

[latex]t[/latex] |
0 | 8 | 10 | 17 | 19 | 24 |

[latex]V\left(t\right)[/latex] |
0 | 0 | 220 | 220 | 0 | 0 |

[latex]S\left(t\right)[/latex] |
20 | 20 | 240 | 240 | 20 | 20 |

### 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]f\left(x\right)\\[/latex] is given below. Create a table for the function [latex]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 |

### Solution

The formula [latex]g\left(x\right)=f\left(x\right)-3\\[/latex] tells us that we can find the output values of [latex]g[/latex] by subtracting 3 from the output values of [latex]f[/latex]. For example:

Subtracting 3 from each [latex]f\left(x\right)[/latex] value, we can complete a table of values for [latex]g\left(x\right)\\[/latex].

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

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

[latex]g\left(x\right)[/latex] |
−2 | 0 | 4 | 8 |

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

**Figure 5.** Horizontal shift of the function [latex]f\left(x\right)=\sqrt[3]{x}\\[/latex]. Note that [latex]h=+1[/latex] shifts the graph to the left, that is, towards *negative* values of [latex]x[/latex].

For example, if [latex]f\left(x\right)={x}^{2}\\[/latex], then [latex]g\left(x\right)={\left(x - 2\right)}^{2}\\[/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]f[/latex].

### A General Note: Horizontal Shift

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

### Example 3: Adding a Constant to an Input

Returning to our building airflow example from Example 2, 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.

### Solution

We can set [latex]V\left(t\right)[/latex] to be the original program and [latex]F\left(t\right)[/latex] to be the revised program.

In the new graph, at each time, the airflow is the same as the original function [latex]V[/latex] was 2 hours later. For example, in the original function [latex]V[/latex], the airflow starts to change at 8 a.m., whereas for the function [latex]F[/latex], the airflow starts to change at 6 a.m. The comparable function values are [latex]V\left(8\right)=F\left(6\right)\\[/latex]. Notice also that the vents first opened to [latex]220{\text{ ft}}^{2}\\[/latex] at 10 a.m. under the original plan, while under the new plan the vents reach [latex]220{\text{ ft}}^{\text{2}}\\[/latex] at 8 a.m., so [latex]V\left(10\right)=F\left(8\right)\\[/latex].

**Figure 6**

In both cases, we see that, because [latex]F\left(t\right)\\[/latex] starts 2 hours sooner, [latex]h=-2[/latex]. That means that the same output values are reached when [latex]F\left(t\right)=V\left(t-\left(-2\right)\right)=V\left(t+2\right)\\[/latex].

### Analysis of the Solution

Note that [latex]V\left(t+2\right)\\[/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]F\left(t\right)\\[/latex] uses the same outputs as [latex]V\left(t\right)\\[/latex], but matches those outputs to inputs 2 hours earlier than those of [latex]V\left(t\right)\\[/latex]. Said another way, we must add 2 hours to the input of [latex]V[/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 4: Shifting a Tabular Function Horizontally

A function [latex]f\left(x\right)\\[/latex] is given below. Create a table for the function [latex]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 |

### Solution

The formula [latex]g\left(x\right)=f\left(x - 3\right)\\[/latex] tells us that the output values of [latex]g[/latex] are the same as the output value of [latex]f[/latex] when the input value is 3 less than the original value. For example, we know that [latex]f\left(2\right)=1\\[/latex]. To get the same output from the function [latex]g[/latex], we will need an input value that is 3 *larger*. We input a value that is 3 larger for [latex]g\left(x\right)[/latex] because the function takes 3 away before evaluating the function [latex]f[/latex].

We continue with the other values to create this table.

[latex]x[/latex] |
5 | 7 | 9 | 11 |

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

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

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

The result is that the function [latex]g\left(x\right)[/latex] has been shifted to the right by 3. Notice the output values for [latex]g\left(x\right)[/latex] remain the same as the output values for [latex]f\left(x\right)[/latex], but the corresponding input values, [latex]x[/latex], have shifted to the right by 3. Specifically, 2 shifted to 5, 4 shifted to 7, 6 shifted to 9, and 8 shifted to 11.

### Analysis of the Solution

The graph in Figure 7 represents both of the functions. We can see the horizontal shift in each point.**Figure 7**

### Example 5: Identifying a Horizontal Shift of a Toolkit Function

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

### Solution

Notice that the graph is identical in shape to the [latex]f\left(x\right)={x}^{2}[/latex] function, but the *x-*values are shifted to the right 2 units. The vertex used to be at (0,0), but now the vertex is at (2,0). The graph is the basic quadratic function shifted 2 units to the right, so

Notice how we must input the value [latex]x=2[/latex] to get the output value [latex]y=0[/latex]; the* x*-values must be 2 units larger because of the shift to the right by 2 units. We can then use the definition of the [latex]f\left(x\right)[/latex] function to write a formula for [latex]g\left(x\right)[/latex] by evaluating [latex]f\left(x - 2\right)[/latex].

### Analysis of the Solution

To determine whether the shift is [latex]+2[/latex] or [latex]-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]f\left(0\right)=0[/latex]. In our shifted function, [latex]g\left(2\right)=0[/latex]. To obtain the output value of 0 from the function [latex]f[/latex], we need to decide whether a plus or a minus sign will work to satisfy [latex]g\left(2\right)=f\left(x - 2\right)=f\left(0\right)=0\\[/latex]. For this to work, we will need to *subtract* 2 units from our input values.

### Example 6: Interpreting Horizontal versus Vertical Shifts

The function [latex]G\left(m\right)[/latex] gives the number of gallons of gas required to drive [latex]m[/latex] miles. Interpret [latex]G\left(m\right)+10\\[/latex] and [latex]G\left(m+10\right)\\[/latex].

### Solution

[latex]G\left(m\right)+10[/latex] can be interpreted as adding 10 to the output, gallons. This is the gas required to drive [latex]m[/latex] miles, plus another 10 gallons of gas. The graph would indicate a vertical shift.

[latex]G\left(m+10\right)[/latex] can be interpreted as adding 10 to the input, miles. So this is the number of gallons of gas required to drive 10 miles more than [latex]m[/latex] miles. The graph would indicate a horizontal shift.

### Try It 1

Given the function [latex]f\left(x\right)=\sqrt{x}\\[/latex], graph the original function [latex]f\left(x\right)\\[/latex] and the transformation [latex]g\left(x\right)=f\left(x+2\right)\\[/latex] on the same axes. Is this a horizontal or a vertical shift? Which way is the graph shifted and by how many units?

Solution## Licenses & Attributions

### CC licensed content, Shared previously

- Precalculus.
**Provided by:**OpenStax**Authored by:**Jay Abramson, et al..**Located at:**https://openstax.org/books/precalculus/pages/1-introduction-to-functions.**License:**CC BY: Attribution.**License terms:**Download For Free at : http://cnx.org/contents/[email protected]..

## Analysis of the Solution

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