Sub topic 4
Moving a Graph Left and Right
This chapter covers horizontal shifts: how replacing x with x − h inside a function slides its graph sideways. It assumes you can evaluate f(x) from function notation, plot points, sketch the basic graphs (x, x², |x|, √x, x³), and find a domain and range. It also builds on the previous chapter's distinction between changing the output (f(x) + k) and changing the input.
The rule
Let f be any function and h any real number. Define a new function:
g(x) = f(x − h)The graph of g is the graph of f moved h units horizontally.
- If
h > 0, the graph moves right. - If
h < 0, the graph moves left.
Written with a plus sign, f(x + 3) is f(x − (−3)), so h = −3 and the graph moves 3 units left.
| Function | Value of h | Movement of the graph of f |
|---|---|---|
| `f(x − 2)` | 2 | 2 units right |
| `f(x − 7)` | 7 | 7 units right |
| `f(x + 4)` | −4 | 4 units left |
| `f(x + 0.5)` | −0.5 | 0.5 units left |
Why the direction feels backward
Most learners expect x + 3 to move a graph right, because "plus" suggests "more". The sign makes sense once you ask which input to g produces a given output.
Take f(x) = x², which reaches its lowest value, 0, at x = 0. Now look at g(x) = (x − 3)². For g to reach 0, the expression inside the parentheses must be 0:
x − 3 = 0 → x = 3The input that used to be 0 is now 3. In general, g produces the value f(c) when x − h = c, which means x = c + h. Every feature of f that occurred at input c now occurs at input c + h. That is a shift of h to the right, and the sign of h is the opposite of the sign you see in x − h.
Here is the same idea as a data flow. The shift happens before f sees the input.
Because the change happens to the input, it works against the direction you would guess. To get f's old behavior at x = 0 you must now supply x = h. The graph has to move to meet it.
Worked examples
Start with f(x) = |x|, whose vertex is at (0, 0).
g(x) = |x − 5|. Hereh = 5. The vertex moves to(5, 0), and the graph opens upward as before.g(x) = |x + 4|. Rewrite it as|x − (−4)|, soh = −4. The vertex moves to(−4, 0).
Now try a function with a restricted domain. For f(x) = √x, the domain is x ≥ 0 and the range is y ≥ 0.
g(x) = √(x − 1)requiresx − 1 ≥ 0, so the domain isx ≥ 1. The range is stilly ≥ 0.g(x) = √(x + 2)requiresx + 2 ≥ 0, so the domain isx ≥ −2. The range is stilly ≥ 0.
The starting point of the curve moves from (0, 0) to (1, 0) in the first case and to (−2, 0) in the second.
A function with an asymptote shows the same behavior. For f(x) = 1/x, the vertical asymptote is x = 0. For g(x) = 1/(x − 2), the denominator is zero at x = 2, so the vertical asymptote moves to x = 2. The horizontal asymptote y = 0 does not move.
Mapping points
A horizontal shift changes every x-coordinate by the same amount and leaves every y-coordinate alone:
(x, y) on f → (x + h, y) on gFor f(x) = x² shifted by h = 3:
| Point on f | Point on g(x) = (x − 3)² |
|---|---|
| (−2, 4) | (1, 4) |
| (0, 0) | (3, 0) |
| (2, 4) | (5, 4) |
Check one: g(5) = (5 − 3)² = 4, which matches (5, 4).
This rule uses + h on the x-coordinate, so it looks like the equation has the opposite sign. This is the same effect described above. The equation contains x − h, and the points move by + h.
Checking a shift in code
The function below builds a shifted version of any function, so you can test the rule on real values.
import math
def shift_right(f, h):
"""Return g(x) = f(x - h). A negative h shifts left."""
return lambda x: f(x - h)
square = lambda x: x ** 2
g = shift_right(square, 3)
print(g(3)) # 0 (the old minimum at x = 0 is now at x = 3)
print(g(5)) # 4 (same height that square had at x = 2)
print(g(1)) # 4 (same height that square had at x = -2)
root = shift_right(math.sqrt, -2) # g(x) = sqrt(x + 2)
print(root(-2)) # 0.0
print(root(2)) # 2.0
try:
root(-3)
except ValueError:
print("-3 is outside the domain x >= -2")The last lines show the domain shifting. math.sqrt rejects negative inputs, and root rejects any x below −2.
What changes and what does not
For a pure horizontal shift by h:
- Domain: shifts by
h. If the domain offis[a, b], the domain ofgis[a + h, b + h]. A domain of all real numbers stays all real numbers. - Range: unchanged. The outputs are the same set of values, only reached at different inputs.
x-intercepts and vertical asymptotes: shift byh.y-intercept: does not move with the graph. It isg(0) = f(−h), and generally has a different value fromf(0).- Horizontal asymptotes and the maximum or minimum value: unchanged.
- Shape: unchanged. The graph is congruent to the original.
Common errors
Reading the sign directly
Writing that f(x + 2) moves right 2 is the most common mistake. Test it with one point. If f(x) = x², then f(x + 2) = (x + 2)² equals 0 when x = −2, so the vertex is at x = −2, which is left.
Shifting before factoring
The rule f(x − h) requires x to appear with a coefficient of 1. Suppose f(x) = x² and g(x) = (2x − 6)². It is tempting to say the graph moves 6 units right. Factor first:
(2x − 6)² = (2(x − 3))²Inside the parentheses, the shift is h = 3. The factor 2 is a horizontal compression, which the next chapters cover. The vertex is at x = 3, not x = 6. You can confirm this by solving 2x − 6 = 0.
Another example: g(x) = |3x + 6| = |3(x + 2)|. The shift is 2 units left, and there is also a horizontal compression by a factor of 3.
Mixing up the two kinds of shift
Compare these two functions:
| Function | Where the change happens | Effect |
|---|---|---|
| `f(x) + 3` | outside `f`, on the output | up 3 |
| `f(x + 3)` | inside `f`, on the input | left 3 |
Changes outside the function behave as you would expect. Changes inside work against the sign. If you are unsure which is which, ask whether the number touches x before f is applied.
Applying the shift to the wrong part of the formula
For g(x) = (x − 4)² + 1, the − 4 is inside the squaring, so it controls the horizontal shift, and the + 1 is outside, so it controls the vertical shift. The vertex is (4, 1). Reading the formula as (x² − 4) + 1 or misplacing the parentheses leads to a different function entirely, so check where the parentheses fall.
Connection to vertex form
A quadratic written as g(x) = a(x − h)² + k is the parabola y = x² stretched by a, shifted h units horizontally, and shifted k units vertically. The horizontal shift tells you the x-coordinate of the vertex directly. For g(x) = 2(x + 1)² − 5, write x + 1 as x − (−1). Then h = −1 and the vertex is (−1, −5).
Summary
g(x) = f(x − h)moves the graph offright byhifh > 0and left ifh < 0.- The shift acts on the input, so the direction is opposite to the sign you see. A feature at input
cmoves to inputc + h. - Points map by
(x, y) → (x + h, y). The domain shifts, and the range does not. - Factor out the coefficient of
xbefore readingh. Inf(2x − 6), the shift is 3, not 6.
Exercise
Describe how the graph of g(x) = √(x + 5) relates to the graph of f(x) = √x. Give the domain and range of g, and the starting point of its curve.
Show answer
Write x + 5 as x − (−5), so h = −5. The graph shifts 5 units left. The domain requires x + 5 ≥ 0, so x ≥ −5, which is [−5, ∞). The range is unchanged: y ≥ 0. The curve starts at (−5, 0), where f started at (0, 0).
Exercise
The graph of g(x) = |2x − 8| is a transformation of f(x) = |x|. Find the x-coordinate of the vertex, and explain why the shift is not 8 units.
Show answer
Factor the coefficient of x: |2x − 8| = |2(x − 4)|. The horizontal shift is h = 4, so the graph moves 4 units right. The 2 is a horizontal compression, not part of the shift. The vertex is at x = 4, which you can also find by solving 2x − 8 = 0. The vertex is (4, 0).
Exercise
A function f has the points (−1, 3), (0, 1), and (2, 5) on its graph. g(x) = f(x + 2). List the corresponding points on the graph of g, and state g(0) in terms of f.
Show answer
Here h = −2, so each point maps by (x, y) → (x − 2, y). The points on g are (−3, 3), (−2, 1), and (0, 5). Also g(0) = f(0 + 2) = f(2) = 5, which agrees with the point (0, 5).