# 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 $\text{}f\left(x\right),\text{}$ a new function $\text{}g\left(x\right)=af\left(x\right),\text{}$ where $\text{}a\text{}$ is a constant, is a vertical stretch or vertical compression of the function $\text{}f\left(x\right)$.

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

### How To

Given a function, graph its vertical stretch.

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

### Example 1: Graphing a Vertical Stretch

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

A scientist is comparing this population to another population, $\text{}Q\text{}$, 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.

1. Determine the value of $\text{}a$.
2. Multiply all of the output values by $\text{}a$.

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

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

 $x$ $f\left(x\right)\text{}$ 2 4 6 8 1 3 7 11

#### Analysis

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

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

 $x$ $f\left(x\right)$ 2 4 6 8 12 16 20 0

### Example 3: Recognizing a Vertical Stretch

The graph in Figure 3-15 is a transformation of the toolkit function $\text{}f\left(x\right)={x}^{3}\text{}$. Relate this new function $\text{}g\left(x\right)\text{}$ to $\text{}f\left(x\right)\text{}$, and then find a formula for $\text{}g\left(x\right)$.

### 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 $\text{}y=f\left(x\right)\text{}$, the form $\text{}y=f\left(bx\right)\text{}$ results in a horizontal stretch or compression. Consider the function $\text{}y={x}^{2}\text{}$. Observe Figure 3-16. The graph of $\text{}y={\left(0.5x\right)}^{2}\text{}$ is a horizontal stretch of the graph of the function $\text{}y={x}^{2}\text{}$ by a factor of 2. The graph of $\text{}y={\left(2x\right)}^{2}\text{}$ is a horizontal compression of the graph of the function $\text{}y={x}^{2}\text{}$ by a factor of $\text{}\frac{1}{2}$.

### Horizontal Stretches and Compressions

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

• If $\text{}b>1\text{}$, then the graph will be compressed by $\text{}\frac{1}{b}$.
• If $\text{}0 < b < 1\text{}$, then the graph will be stretched by $\text{}\frac{1}{b}$.
• If $\text{}b<0\text{}$, 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.

1. Write a formula to represent the function.
2. Set $\text{}g\left(x\right)=f\left(bx\right)\text{}$ where $\text{}b>1\text{}$ for a compression or $\text{}0 < b < 1\text{}$ 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, $\text{}R\text{}$, 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 $\text{}f\left(x\right)\text{}$ is given as Table 7. Create a table for the function $\text{}g\left(x\right)=f\left(\frac{1}{2}x\right)$.

 $x$ $f\left(x\right)$ 2 4 6 8 1 3 7 11

#### Analysis

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

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

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

### Combining Transformations

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

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

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

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 $\text{}f\left(x\right)\text{}$, create a table of values for the function $\text{}g\left(x\right)=2f\left(3x\right)+1$.

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

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

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