Sub topic 6
Stretching and Compressing Horizontally
This chapter covers the transformation f(x) → f(bx). It assumes you can evaluate f(x), plot points, and recognize the graphs of x, x², |x|, √x, and x³. It also assumes you know how domain and range are written. It builds on the earlier chapters on vertical shifts, horizontal shifts, and vertical stretches. If "the input acts opposite to the sign" is still unfamiliar, review the horizontal shifts chapter first.
The rule
Multiplying the input by a positive constant b changes the graph of f horizontally:
- If b > 1, the graph of g(x) = f(bx) is compressed horizontally by the factor 1/b. It is squeezed toward the y-axis.
- If 0 < b < 1, the graph is stretched horizontally by the factor 1/b. It is pulled away from the y-axis.
Every point (x, y) on f becomes the point (x/b, y). The y-coordinate is unchanged because the output rule is untouched. Only the input is rescaled.
| g(x) | b | Effect on the graph of f | Point (x, y) moves to |
|---|---|---|---|
| f(2x) | 2 | Compressed to half the width | (x/2, y) |
| f(3x) | 3 | Compressed to one third the width | (x/3, y) |
| f(x/2) | 1/2 | Stretched to twice the width | (2x, y) |
| f(x/4) | 1/4 | Stretched to four times the width | (4x, y) |
Why the factor is 1/b
Beginners usually expect f(2x) to stretch the graph, because 2 is bigger than 1. The mistake comes from reading the constant as acting on the graph. It acts on the input.
Take g(x) = f(2x). The function g produces the value f(c) when its input satisfies 2x = c, so x = c/2. Every value that f reaches at input c, g reaches at input c/2. The same picture is therefore traced out in half the horizontal distance.
This is the same reasoning that made f(x − 3) move right by 3. The input has to be "undone" to find where the old feature lands. A shift is undone by adding h, and a scale is undone by dividing by b.
A worked example
Let f(x) = √(4 − x²). Its graph is the upper half of a circle of radius 2. The key points are (−2, 0), (0, 2), and (2, 0). The domain is [−2, 2] and the range is [0, 2].
Now define g(x) = f(2x) and h(x) = f(x/2). For g to be defined, the expression 2x must lie in [−2, 2]. That gives x in [−1, 1]. For h, x/2 must lie in [−2, 2], which gives x in [−4, 4].
import math
def f(x):
return math.sqrt(4 - x ** 2)
def horizontal(f, b):
"""Return g(x) = f(b * x)."""
return lambda x: f(b * x)
g = horizontal(f, 2) # compressed by 1/2
h = horizontal(f, 0.5) # stretched by 2
print(g(0), g(1), g(-1)) # 2.0 0.0 0.0 (half-circle now spans -1 to 1)
print(h(0), h(4), h(-4)) # 2.0 0.0 0.0 (half-ellipse now spans -4 to 4)The peak stays at height 2 in both cases, because the range is unchanged. Only the width differs. The graph of g is a half-ellipse that is narrow and tall. The graph of h is wide and flat.
Tracking points with the mapping rule
The rule (x, y) → (x/b, y) is the horizontal part of the general mapping (x, y) → (x/b + h, a·y + k) from the plan for this tutorial. Use it to move key points directly, with no new table of values.
points = [(-2, 0), (-1, 1), (1, 1), (2, 0)]
for b in (2, 0.5, -1):
mapped = [(x / b, y) for x, y in points]
print(b, mapped)
# 2 [(-1.0, 0), (-0.5, 1), (0.5, 1), (1.0, 0)]
# 0.5 [(-4.0, 0), (-2.0, 1), (2.0, 1), (4.0, 0)]
# -1 [(2.0, 0), (1.0, 1), (-1.0, 1), (-2.0, 0)]The last row uses b = −1. A negative b combines a reflection across the y-axis with a scaling by |b|. That case gets its own section below.
The procedure for any horizontal scaling is:
Negative values of b
If b is negative, write b = −|b|. Then f(bx) = f(−|b|·x). Two things happen: the graph is scaled horizontally by 1/|b|, and it is reflected across the y-axis. The two steps give the same result in either order, because both act on the x-coordinate by multiplication.
The point-mapping rule handles this case without special treatment. Dividing x by a negative number flips its sign and scales it in one move. The next chapters on reflections and on even and odd symmetry develop the reflection part further.
Horizontal scaling and the other transformations
Pairing with horizontal shifts
A horizontal shift and a horizontal scale are both changes to the input. The order they are applied in matters, so the written form matters:
- g(x) = f(b(x − h)) scales first, then shifts by h. The shift is exactly h.
- g(x) = f(bx − h) is the same function as f(b(x − h/b)). The shift is h/b.
The second form is where many errors come from. The code below checks it with f(x) = √x, whose graph starts at the point (0, 0).
import math
f = math.sqrt
g1 = lambda x: f(2 * (x - 3)) # factored form: starts at x = 3
g2 = lambda x: f(2 * x - 3) # unfactored form: starts at x = 3/2
print(g1(3)) # 0.0 (starting point is at x = 3)
print(g2(1.5)) # 0.0 (starting point is at x = 1.5)
print(g2(3)) # 1.7320508075688772 (sqrt(3), so g2 has not started at 3)Why f(bx) often looks like a vertical change
For some parent functions, a horizontal scaling gives exactly the same graph as a vertical one. Take f(x) = x². Then f(2x) = 4x², which is the vertical stretch 4·f(x). Likewise f(x/2) = x²/4. For f(x) = √x, f(4x) = 2√x. For any power function f(x) = xⁿ, f(bx) = bⁿ·f(x).
This does not mean the two transformations are the same in general. It happens because power functions scale uniformly. For f(x) = |x|, the relation is f(bx) = |b|·f(x). For a function such as f(x) = √(4 − x²), or for sin(x), the horizontal and vertical versions give different graphs. The semicircle above gets narrower under f(2x) but keeps its height, and no vertical stretch can do that.
What stays the same, and what changes
Horizontal scaling by a positive or negative b has a clean effect on the standard features of a graph:
- The y-intercept is unchanged. If f(0) = c, then g(0) = f(b·0) = c.
- Every x-intercept is divided by b. If f(r) = 0, then g(r/b) = f(r) = 0.
- The range is unchanged, because g produces exactly the same set of output values as f. A scaling by b only changes which input yields each one.
- The domain is divided by b. If f has domain [p, q] and b > 0, then g has domain [p/b, q/b]. If b < 0, the endpoints swap order, giving [q/b, p/b].
- A vertical asymptote at x = c moves to x = c/b. A horizontal asymptote does not move.
For the semicircle f(x) = √(4 − x²), the x-intercepts −2 and 2 become ±1 for b = 2 and ±4 for b = 1/2. That matches the numbers in the worked example.
Common errors
- Multiplying x-coordinates by b instead of dividing. The correct mapping is x/b. A reliable check is to ask whether f(bx) with b = 2 should look narrower. It should, so the coordinates must shrink.
- Reading the shift from an unfactored input. Writing f(2x − 6) as a shift of 6 is wrong. Factor first.
- Treating "stretch by 2" and f(2x) as the same thing. The function f(2x) is a horizontal compression by 1/2. A horizontal stretch by 2 is f(x/2).
- Changing the range. Pure horizontal scaling never changes the range. If your answer for the range changed, check whether a vertical factor a was also present.
- Forgetting the reflection when b is negative. The factor f(−2x) is both a compression by 1/2 and a y-axis reflection.
- Assuming the effect is visible for every parent function. For x² and |x|, f(bx) looks like a vertical stretch. This is not an error in the graph, only a feature of those functions.
Practice
Exercise
The graph of f has x-intercepts at x = −6 and x = 3 and a y-intercept at (0, 5). Describe the graph of g(x) = f(3x), and give its intercepts.
Show answer
The factor b = 3 is greater than 1, so g is a horizontal compression by the factor 1/3. The x-intercepts are divided by 3, giving x = −2 and x = 1. The y-intercept does not change, so it stays at (0, 5).
Exercise
Let f(x) = √(4 − x²), with domain [−2, 2] and range [0, 2]. Find the domain and range of g(x) = f(x/4), and state what happens to the point (0, 2).
Show answer
Here b = 1/4, so g is a horizontal stretch by the factor 4. The input x/4 must lie in [−2, 2], so x lies in [−8, 8]. The domain is [−8, 8]. The range stays [0, 2]. The point (0, 2) maps to (0/(1/4), 2) = (0, 2), so it does not move.
Exercise
A student reads g(x) = f(2x − 8) as "f compressed by 1/2 and shifted right 8". Correct the reading, and say where the point (4, 7) on f lands on g.
Show answer
Factor the input: 2x − 8 = 2(x − 4). So g is f compressed horizontally by 1/2 and then shifted right by 4, not 8. For the point (4, 7), the x-coordinate becomes x/b + h = 4/2 + 4 = 6, so the point lands at (6, 7). Check: g(6) = f(2·6 − 8) = f(4) = 7.
Exercise
Show that for f(x) = x³, the graph of f(2x) is the same as a vertical stretch of f, and give the stretch factor.
Show answer
f(2x) = (2x)³ = 8x³ = 8·f(x). The horizontal compression by 1/2 produces the same graph as a vertical stretch by the factor 8.