# 3.5 Graphing Functions Using Stretches and Compressions

Adding a constant to the inputs or outputs of a function changed the position of a graph with respect to the axes, but it did not affect the shape of a graph. We now explore the effects of multiplying the inputs or outputs by some quantity.

We can transform the inside (input values) of a function or we can transform the outside (output values) of a function. Each change has a specific effect that can be seen graphically.

## Vertical Stretches and Compressions

When we multiply a function by a positive constant, we get a function whose graph is stretched or compressed vertically in relation to the graph of the original function. If the constant is greater than 1, we get a **vertical stretch**; if the constant is between 0 and 1, we get a **vertical compression**. Figure 3-13 shows a function multiplied by constant factors 2 and 0.5 and the resulting vertical stretch and compression.

**Vertical Stretches and Compressions**

Given a function [latex]\text{}f\left(x\right),\text{}[/latex] a new function [latex]\text{}g\left(x\right)=af\left(x\right),\text{}[/latex] where [latex]\text{}a\text{}[/latex] is a constant, is a **vertical stretch** or** vertical compression** of the function [latex]\text{}f\left(x\right)[/latex].

- If [latex]\text{}a>1\text{}[/latex], then the graph will be stretched.
- If [latex]\text{}0 < a<1\text{}[/latex], then the graph will be compressed.
- If [latex]\text{}a<0\text{}[/latex], then there will be combination of a vertical stretch or compression with a vertical reflection.

**How To**

**Given a function, graph its vertical stretch.**

- Identify the value of [latex]\text{}a[/latex].
- Multiply all range values by [latex]\text{}a[/latex].
- If [latex]\text{}\text{}a>1\text{}\text{}[/latex], the graph is stretched by a factor of [latex]\text{}a[/latex]. If [latex]\text{} 0 < a < 1\text{}[/latex], the graph is compressed by a factor of [latex]\text{}a[/latex]. If [latex]a < 0[/latex], the graph is either stretched or compressed and also reflected about the
*x*-axis.

**Example 1: Graphing a Vertical Stretch**

A function [latex]\text{}P\left(t\right)\text{}[/latex] models the population of fruit flies. The graph is shown in Figure 3-14.

A scientist is comparing this population to another population, [latex]\text{}Q\text{}[/latex], whose growth follows the same pattern, but is twice as large. Sketch a graph of this population.

**How To**

**Given a tabular function and assuming that the transformation is a vertical stretch or compression, create a table for a vertical compression. **

- Determine the value of [latex]\text{}a[/latex].
- Multiply all of the output values by [latex]\text{}a[/latex].

**Example 2: Finding a Vertical Compression of a Tabular Function**

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

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

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

#### Analysis

The result is that the function [latex]\text{}g\left(x\right)\text{}[/latex] has been compressed vertically by [latex]\text{}\frac{1}{2}\text{}[/latex]. Each output value is divided in half, so the graph is half the original height.

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

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

[latex]f\left(x\right)[/latex] | 12 | 16 | 20 | 0 |

**Example 3: Recognizing a Vertical Stretch**

The graph in Figure 3-15 is a transformation of the toolkit function [latex]\text{}f\left(x\right)={x}^{3}\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].

**Example 4: Vertical Stretch**

Write the formula for the function that we get when we stretch the identity toolkit function by a factor of 3, and then shift it down by 2 units.

## Horizontal Stretches and Compressions

Now we consider changes to the inside of a function. When we multiply a function’s input by a positive constant, we get a function whose graph is stretched or compressed horizontally in relation to the graph of the original function. If the constant is between 0 and 1, we get a **horizontal stretch**; if the constant is greater than 1, we get a **horizontal compression** of the function.

Given a function [latex]\text{}y=f\left(x\right)\text{}[/latex], the form [latex]\text{}y=f\left(bx\right)\text{}[/latex] results in a horizontal stretch or compression. Consider the function [latex]\text{}y={x}^{2}\text{}[/latex]. Observe Figure 3-16. The graph of [latex]\text{}y={\left(0.5x\right)}^{2}\text{}[/latex] is a horizontal stretch of the graph of the function [latex]\text{}y={x}^{2}\text{}[/latex] by a factor of 2. The graph of [latex]\text{}y={\left(2x\right)}^{2}\text{}[/latex] is a horizontal compression of the graph of the function [latex]\text{}y={x}^{2}\text{}[/latex] by a factor of [latex]\text{}\frac{1}{2}[/latex].

**Horizontal Stretches and Compressions**

Given a function [latex]\text{}f\left(x\right)\text{}[/latex], a new function [latex]\text{}g\left(x\right)=f\left(bx\right)\text{}[/latex], where [latex]\text{}b\text{}[/latex] is a constant, is a horizontal stretch or horizontal compression of the function [latex]\text{}f\left(x\right)[/latex].

- If [latex]\text{}b>1\text{}[/latex], then the graph will be compressed by [latex]\text{}\frac{1}{b}[/latex].
- If [latex]\text{}0 < b < 1\text{}[/latex], then the graph will be stretched by [latex]\text{}\frac{1}{b}[/latex].
- If [latex]\text{}b<0\text{}[/latex], then there will be combination of a horizontal stretch or compression with a horizontal reflection.

**How To**

**Given a description of a function, sketch a horizontal compression or stretch. **

- Write a formula to represent the function.
- Set [latex]\text{}g\left(x\right)=f\left(bx\right)\text{}[/latex] where [latex]\text{}b>1\text{}[/latex] for a compression or [latex]\text{}0 < b < 1\text{}[/latex] for a stretch.

**Example 5: Graphing a Horizontal Compression**

Suppose a scientist is comparing a population of fruit flies to a population that progresses through its lifespan twice as fast as the original population. In other words, this new population, [latex]\text{}R\text{}[/latex], will progress in 1 hour the same amount as the original population does in 2 hours, and in 2 hours, it will progress as much as the original population does in 4 hours. Sketch a graph of this population.

#### Analysis

Note that the effect on the graph is a horizontal compression where all input values are half of their original distance from the vertical axis.

**Example 6: Finding a Horizontal Stretch for a Tabular Function**

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

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

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

#### Analysis

Because each input value has been doubled, the result is that the function [latex]\text{}g\left(x\right)\text{}[/latex] has been stretched horizontally by a factor of 2.

**Example 7: Recognizing a Horizontal Compression on a Graph**

Relate the function [latex]\text{}g\left(x\right)\text{}[/latex] to [latex]\text{}f\left(x\right)\text{}[/latex] in Figure 3-17.

#### Analysis

Notice that the coefficient needed for a horizontal stretch or compression is the reciprocal of the stretch or compression. So to stretch the graph horizontally by a scale factor of 4, we need a coefficient of [latex]\text{}\frac{1}{4}\text{}[/latex] in our function: [latex]\text{}f\left(\frac{1}{4}x\right)\text{}[/latex]. This means that the input values must be four times larger to produce the same result, requiring the input to be larger, causing the horizontal stretching.

**Example 8: Horizontal Stretch**

Write a formula for the toolkit square root function horizontally stretched by a factor of 3.

## 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 [latex]\text{}\text{}2f\left(x\right)+3\text{}[/latex], which transformation should we start with? The answer here follows nicely from the order of operations. Given the output value of [latex]\text{}f\left(x\right)\text{}[/latex], 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 [latex]\text{}g\left(x\right)=f\left(2x+3\right)\text{}[/latex], for example, we have to think about how the inputs to the function [latex]\text{}g\text{}[/latex] relate to the inputs to the function [latex]\text{}\text{}f\text{}[/latex]. Suppose we know [latex]\text{}f\left(7\right)=12\text{}[/latex]. What input to [latex]\text{}g\text{}[/latex] would produce that output? In other words, what value of [latex]\text{}x\text{}[/latex] will allow [latex]\text{}g\left(x\right)=f\left(2x+3\right)=12\text{}[/latex]? We would need [latex]\text{}2x+3=7\text{}[/latex]. To solve for [latex]\text{}x\text{}[/latex], 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.

[latex]f\left(bx+p\right)=f\left(b\left(x+\frac{p}{b}\right)\right)[/latex]

Let’s work through an example.

[latex]f\left(x\right)={\left(2x+4\right)}^{2}[/latex]

We can factor out a 2.

[latex]f\left(x\right)={\left(2\left(x+2\right)\right)}^{2}[/latex]

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.

**Combining Transformations**

When combining vertical transformations written in the form [latex]\text{}af\left(x\right)+k,\text{}[/latex] first vertically stretch by [latex]\text{}a\text{}[/latex] and then vertically shift by [latex]\text{}k[/latex].

When combining horizontal transformations written in the form [latex]\text{}f\left(bx-h\right)\text{}[/latex], first horizontally shift by [latex]\text{}h\text{}[/latex] and then horizontally stretch by [latex]\text{}\frac{1}{b}[/latex].

When combining horizontal transformations written in the form [latex]\text{}f\left(b\left(x-h\right)\right)\text{}[/latex], first horizontally stretch by [latex]\text{}\frac{1}{b}\text{}[/latex] and then horizontally shift by [latex]\text{}h[/latex].

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

**Example 9: Finding a Triple Transformation of a Tabular Function**

Given Table 8 for the function [latex]\text{}f\left(x\right)\text{}[/latex], create a table of values for the function [latex]\text{}g\left(x\right)=2f\left(3x\right)+1[/latex].

[latex]x[/latex] |
6 | 12 | 18 | 24 |
---|---|---|---|---|

[latex]f\left(x\right)[/latex] |
10 | 14 | 15 | 17 |

**Example 10: Finding a Triple Transformation of a Graph**

Use the graph of [latex]\text{}f\left(x\right)\text{}[/latex] in Figure 3-18 to sketch a graph of [latex]\text{}k\left(x\right)=f\left(\frac{1}{2}x+1\right)-3[/latex].

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