Sub topic 3
Moving a Graph Up and Down
This chapter covers vertical shifts: what happens to a graph when you add a constant to the output of a function. It assumes you can evaluate f(x) from function notation, plot points on the coordinate plane, recognize the graphs of x, x², |x|, √x, and x³, and find the domain and range of a function.
The idea in one line
If you know the graph of y = f(x), then the graph of y = f(x) + k is the same shape moved vertically by k units.
- If k > 0, the graph moves up k units.
- If k < 0, the graph moves down |k| units.
- If k = 0, nothing changes.
The shape, width, and orientation stay the same. Only the position changes.
Why adding to the output moves the graph vertically
A point on the graph of f is a pair (x, f(x)). The second coordinate is the height. The function g(x) = f(x) + k takes the same input x and produces an output that is k larger. So for every x:
- The point (x, f(x)) on the original graph becomes (x, f(x) + k) on the new graph.
- The x-coordinate does not change.
- The y-coordinate gains k.
Every point moves straight up or straight down by the same amount. Since every point moves together, the whole graph is translated (slid without turning or resizing) as one piece.
This is the first of the two ways to change a function from the previous chapter. Here you change the output, after the function has done its work. Changes to the output behave the way the sign suggests: add a positive number and the graph goes up.
A worked example
Let f(x) = x². Compare three functions:
- f(x) = x²
- g(x) = x² + 3
- h(x) = x² − 2
Here is a table of values.
| x | f(x) = x² | g(x) = x² + 3 | h(x) = x² − 2 |
|---|---|---|---|
| -2 | 4 | 7 | 2 |
| -1 | 1 | 4 | -1 |
| 0 | 0 | 3 | -2 |
| 1 | 1 | 4 | -1 |
| 2 | 4 | 7 | 2 |
Each entry in the g column is 3 more than the f entry in the same row. Each entry in the h column is 2 less. The vertex (the lowest point of the parabola) moves from (0, 0) to (0, 3) for g and to (0, −2) for h.
Testing the idea in code
The next function builds g(x) = a·f(b(x − h)) + k from any f. For this chapter only k matters, so the other parameters keep their defaults (a = 1, b = 1, h = 0).
def transform(f, a=1, b=1, h=0, k=0):
"""Return g(x) = a * f(b * (x - h)) + k."""
return lambda x: a * f(b * (x - h)) + k
f = lambda x: x ** 2
up = transform(f, k=3)
down = transform(f, k=-2)
for x in range(-2, 3):
print(x, f(x), up(x), down(x))Running it prints each x with the three outputs. The second number in each row is f(x). The third is always 3 more, and the fourth is always 2 less. That is a vertical shift.
Vertical shifts of other parent functions
The rule works for every function. You do not need new rules for each parent function.
| Function | Shifted function | Key point moves from | to | Column | Column | Column | Column |
|---|---|---|---|---|---|---|---|
| f(x) = \ | x\ | \ | x\ | + 2 | (0, 0) | (0, 2) | |
| f(x) = √x | √x − 1 | (0, 0) | (0, −1) | ||||
| f(x) = x³ | x³ + 4 | (0, 0) | (0, 4) | ||||
| f(x) = x | x − 3 | (0, 0) | (0, −3) |
The last row shows something worth noticing. Shifting the line y = x down 3 units gives y = x − 3. That is the same as the familiar y = mx + b with m = 1 and b = −3. The y-intercept b in slope-intercept form is a vertical shift of y = mx.
Effect on the key features
A vertical shift changes some features of a graph and leaves others alone.
| Feature | Effect of f(x) + k |
|---|---|
| Shape and width | Unchanged |
| Direction of opening, increasing or decreasing intervals | Unchanged (the x-values where the graph rises or falls are the same) |
| x-coordinates of key points | Unchanged |
| y-coordinates of key points | Increase by k |
| y-intercept | Moves from f(0) to f(0) + k |
| x-intercepts (zeros) | Usually change, since they are where f(x) + k = 0 |
| Domain | Unchanged |
| Range | Shifts by k |
| Horizontal asymptote, if any | Shifts by k |
Domain and range
Adding k to every output shifts every output value by k, so the range moves by k. The domain is the set of allowed inputs, and the shift does nothing to the inputs.
For f(x) = √x, the domain is x ≥ 0 and the range is y ≥ 0. For g(x) = √x − 1:
- Domain: x ≥ 0 (unchanged).
- Range: y ≥ −1 (the old lower bound 0 plus k = −1).
For f(x) = x², the range is y ≥ 0. For g(x) = x² + 3, the range is y ≥ 3. For h(x) = x² − 2, the range is y ≥ −2.
Intercepts and zeros
The y-intercept is easy: it is g(0) = f(0) + k. For x² + 3 it is 3.
The x-intercepts are less predictable. You need to solve f(x) + k = 0, which is the same as f(x) = −k. Think of it as asking where the original graph crosses the horizontal line y = −k.
Consider g(x) = x² − 4. Setting x² − 4 = 0 gives x = 2 or x = −2, so there are two x-intercepts. But x² + 3 = 0 has no real solution, so the graph never touches the x-axis. A shift can create, remove, or move zeros.
f = lambda x: x ** 2
def zeros_of_shifted_square(k):
# Solve x**2 + k = 0 over the real numbers.
if k > 0:
return []
if k == 0:
return [0.0]
root = (-k) ** 0.5
return [-root, root]
for k in (3, 0, -4):
print(k, zeros_of_shifted_square(k))
# 3 []
# 0 [0.0]
# -4 [-2.0, 2.0]Common errors
- Moving the wrong way. Some learners expect f(x) − 2 to move up because "minus" feels like it removes something. The output is the height. Subtracting lowers it.
- Shifting the x-coordinates. In a vertical shift the point (a, b) becomes (a, b + k), not (a + k, b). Keep the input unchanged.
- Confusing f(x) + k with f(x + k). The first adds to the output and moves the graph vertically. The second adds to the input and moves it horizontally, in the opposite direction from the sign. That is the next chapter. Always check where the constant sits: outside the function (after f has finished) or inside the parentheses.
- Shifting the range by the wrong amount. If the range is y ≥ 0 and k = 5, the new range is y ≥ 5, not y ≥ −5.
- Assuming the zeros move by k. They do not. Only the y-values move by k. Zeros come from solving a new equation.
Reading a shift from a graph
To find k from a graph:
- Identify the parent function from the shape.
- Locate a recognizable key point on the parent graph: the vertex of a parabola or absolute value graph, the starting point of a square root graph, or the center of a cubic.
- Find where that point is on the new graph.
- Subtract the y-coordinates: k = (new y) − (old y).
Example: a graph has the V shape of |x|, and its corner is at (0, −5). The parent corner is at (0, 0), so k = −5 − 0 = −5, and the equation is g(x) = |x| − 5.
You can check this with a second point. The parent graph passes through (2, 2). The shifted graph should pass through (2, 2 − 5) = (2, −3), and indeed |2| − 5 = −3.
Shifts compose by adding
If you shift up 3 and then shift down 5, the result is f(x) + 3 − 5 = f(x) − 2, a net shift of 2 units down. Vertical shifts simply add. The order does not matter when only vertical shifts are involved, because addition is commutative.
Order starts to matter once you mix shifts with stretches or reflections. For example, 2f(x) + 3 (stretch, then shift) differs from 2(f(x) + 3) = 2f(x) + 6 (shift, then stretch). A later chapter covers this in detail.
f = lambda x: abs(x)
step1 = lambda x: f(x) + 3
step2 = lambda x: step1(x) - 5
net = lambda x: f(x) - 2
print(all(step2(x) == net(x) for x in range(-5, 6))) # TrueExercises
Exercise
The graph of f(x) = √x is shifted to give g(x) = √x + 4. State the domain and range of g, and give the coordinates of the point on g that corresponds to (9, 3) on f.
Show answer
The domain stays x ≥ 0 because the inputs are unchanged. The range moves up 4 from y ≥ 0 to y ≥ 4. The point (9, 3) becomes (9, 3 + 4) = (9, 7). Check: √9 + 4 = 7.
Exercise
A graph has the shape of y = x³ and passes through the point (0, −6). Write its equation. Then predict where it crosses the y-axis if you shift it up 10 more units.
Show answer
The center of y = x³ is at (0, 0) and the new center is at (0, −6), so k = −6 and the equation is g(x) = x³ − 6. Shifting up 10 more gives x³ − 6 + 10 = x³ + 4, which crosses the y-axis at (0, 4).
Exercise
Does g(x) = x² + 5 have any x-intercepts? Does h(x) = x² − 5? Explain using the idea that zeros come from solving f(x) = −k.
Show answer
For g, solve x² = −5. A square is never negative, so there is no real solution and no x-intercepts. The lowest point of the graph is (0, 5), above the x-axis. For h, solve x² = 5, so x = √5 or x = −√5. There are two x-intercepts, at about ±2.236.