Sub topic 11
Writing an equation from a graph
Earlier chapters took an equation and drew the graph. This chapter runs the process backward. You are given a graph and must recover an equation of the form g(x) = a·f(b(x − h)) + k. This chapter assumes you can:
- evaluate a function at a point
- recognize the graphs of x, x², |x|, √x, and x³
- apply the shift, stretch, and reflection rules from the earlier chapters
- read the domain and range of a graph
The strategy in one pass
Writing an equation from a graph is detective work. Each feature of the graph fixes one parameter, and a single extra point fixes the last one. Work in this order:
- Name the parent function from the overall shape.
- Find the anchor point, the parent's characteristic point after it has moved. This is the vertex of a parabola or V, the start of a square root, or the center of a cube. Its coordinates give h and k.
- Read the direction of the graph from the anchor. This gives the sign of a, and of b if the shape allows you to tell.
- Pick one clean point on the graph other than the anchor. Substitute it into the template and solve for the remaining stretch factor.
- Verify with a second point, and compare the domain and range of your equation against the graph.
What each feature tells you
| Feature you can read | Parameter | How | Column | Column | Column | Column |
|---|---|---|---|---|---|---|
| x-coordinate of the anchor point | h | g(x) = a·f(b(x − h)) + k, so h is the x-coordinate of the anchor. The sign in the equation is opposite to the sign you "feel" from a left or right shift. | ||||
| y-coordinate of the anchor point | k | k is the y-coordinate of the anchor. A midline or asymptote at y = k gives it too. | ||||
| Graph opens down, or runs downward from the anchor | a < 0 | Reflection across the x-axis. | ||||
| Graph runs to the left of the anchor, when the parent runs right | b < 0 | Reflection across the y-axis. | ||||
| Steepness compared with the parent | \ | a\ | and \ | b\ | Solve from one extra point. | |
| Starting point and direction of a square root | domain boundary | The domain boundary is x = h, or the mirrored equivalent. |
Worked example 1: a parabola
A graph has the shape of a parabola, so the parent is f(x) = x². Its vertex is at (3, 1), it opens downward, and it passes through (4, −1).
The vertex gives h = 3 and k = 1. Opening downward means a < 0. Start from the template with b = 1, which is a safe default for a parabola (see the gotcha below):
g(x) = a(x − 3)² + 1
Substitute the point (4, −1):
−1 = a(4 − 3)² + 1, so −1 = a + 1, so a = −2.
The equation is g(x) = −2(x − 3)² + 1. Check a second point, (2, −1): −2(2 − 3)² + 1 = −2 + 1 = −1. ✓
You can automate the "solve for the stretch factor" step. Rearranging g(x₁) = a·f(b(x₁ − h)) + k gives a = (y₁ − k) / f(b(x₁ − h)).
import math
def solve_a(f, h, k, point, b=1):
"""Solve for a in g(x) = a * f(b * (x - h)) + k using one known point."""
x1, y1 = point
return (y1 - k) / f(b * (x1 - h))
print(solve_a(lambda x: x ** 2, 3, 1, (4, -1))) # -2.0
print(solve_a(math.sqrt, -2, 1, (2, -1))) # -1.0
print(solve_a(abs, 1, -2, (2, 1))) # 3.0The first line reproduces the parabola above. The other two lines belong to the next two examples. The function divides by f(b(x₁ − h)), so it fails if you pick a point where that value is 0. That is the anchor point itself. Always choose a second point away from the anchor.
Worked example 2: a reflected square root
The graph starts at the point (−2, 1) and runs down and to the right. It passes through (2, −1). The shape is a half-parabola on its side, so the parent is f(x) = √x.
The start point gives h = −2 and k = 1. The template is:
g(x) = a√(x + 2) + 1
Note that x − (−2) becomes x + 2. Substitute (2, −1):
−1 = a√4 + 1, so −2 = 2a, so a = −1.
So g(x) = −√(x + 2) + 1. The graph runs downward from the start, which matches a reflection across the x-axis. You can check the domain and range: x + 2 ≥ 0 gives domain x ≥ −2. The square root is at least 0, so −√(x + 2) is at most 0, and the range is y ≤ 1. Both match a graph that starts at (−2, 1) and falls.
import math
g = lambda x: -math.sqrt(x + 2) + 1
print(g(-2), g(2), g(7)) # 1.0 -1.0 -2.0The value g(7) = −3 + 1 = −2 is a fresh point you could read off the graph to confirm the equation.
Worked example 3: reflecting across the y-axis
A square root graph starts at (4, 0), runs to the left, and passes through (0, 2). Because the graph runs left from its start, the horizontal direction is reversed, so b < 0.
Take h = 4, k = 0, and b = −1 as a first try:
g(x) = a√(−(x − 4)) = a√(4 − x)
Substitute (0, 2): 2 = a√4 = 2a, so a = 1. The equation is g(x) = √(4 − x).
The domain is 4 − x ≥ 0, so x ≤ 4. That matches a graph that ends at x = 4 and extends left. The y-axis reflection shows up in the domain, not the range.
Gotcha: when a and b are not separate
For some parents, a vertical stretch and a horizontal compression produce the same graph. You cannot tell them apart from the picture, and you do not need to.
| Parent | Combined form | Equivalent | Column | Column | Column | Column | Column | Column | Column | Column |
|---|---|---|---|---|---|---|---|---|---|---|
| x² | a(b(x − h))² + k | ab²(x − h)² + k | ||||||||
| \ | x\ | a\ | b(x − h)\ | + k | a\ | b\ | ·\ | x − h\ | + k | |
| x³ | a(b(x − h))³ + k | ab³(x − h)³ + k |
For example, in worked example 1 you could write 2(x − 3)² as (√2(x − 3))², and the graphs are identical. For the V-shape in the third solve_a call, the equation 3|x − 1| − 2 equals |3(x − 1)| − 2, since |3(x − 1)| = 3|x − 1|. The vertex is (1, −2) and the point (2, 1) lies on it, since 3·1 − 2 = 1.
The rule is to set b = 1 unless the graph gives you a reason not to. Good reasons are:
- a horizontal reflection you must show, as in √(4 − x)
- a stated period, as with trigonometric functions
- a horizontal stretch given in the problem
For √x, b and a are not interchangeable. Replacing x with bx gives √b·√x, so b = 4 and a = 2 would again be equivalent. The key is to ask whether the graph is distinguishable from one with a different split. If not, take the simplest form.
Using domain and range as a check
Domain and range are the fastest way to catch a wrong sign.
- A square root starting at (h, k) has domain boundary x = h when b > 0, and the domain is x ≥ h. If b < 0 the domain is x ≤ h.
- The range of a√(…) + k is y ≥ k when a > 0 and y ≤ k when a < 0.
- A parabola with vertex (h, k) has range y ≥ k when a > 0 and y ≤ k when a < 0. The domain is all real numbers.
- An absolute value graph follows the same pattern as a parabola for the range.
- A cube-type graph has all real numbers for domain and range, so it gives no boundary to check. Use its center of symmetry (h, k) instead.
After you derive an equation, compute its domain and range and compare them with the picture. If the range runs the wrong way, the sign of a is wrong. If the domain runs the wrong way, the sign of b or the sign of h is wrong.
Common errors
- Reversing the sign of h. A graph that moves right 3 uses x − 3. A graph that moves left 2 uses x + 2.
- Using the wrong anchor. For a parabola the anchor is the vertex, not an x-intercept. For a square root it is the endpoint. For x³ it is the center of symmetry, not an intercept.
- Solving for a with the anchor point. Substituting the anchor gives 0 = a·0, which tells you nothing. Use another point.
- Picking a point that is hard to read. Choose a lattice point, where the graph crosses a grid intersection, so the arithmetic stays exact.
- Skipping verification. One substitution fixes one unknown. A second point catches a mis-read anchor.
Practice
Exercise
A graph has the shape of a cubic. Its center of symmetry is at (−1, 2), and it passes through (0, 0). Write an equation of the form a(x − h)³ + k.
Show answer
The parent is f(x) = x³. The center gives h = −1 and k = 2, so g(x) = a(x + 1)³ + 2. Substituting (0, 0) gives 0 = a(1)³ + 2, so a = −2. The equation is g(x) = −2(x + 1)³ + 2. Check with (−2, 4): −2(−1)³ + 2 = 2 + 2 = 4. ✓
Exercise
A square root graph starts at (1, −3), goes up and to the right, and passes through (5, 1). Write the equation, then state the domain and range.
Show answer
The start gives h = 1 and k = −3, so g(x) = a√(x − 1) − 3. Substituting (5, 1) gives 1 = a√4 − 3 = 2a − 3, so a = 2. The equation is g(x) = 2√(x − 1) − 3. The domain is x ≥ 1 and the range is y ≥ −3.
Exercise
A student reads the equation g(x) = |2x − 8| + 1 and says the vertex is at (8, 1). Find the true vertex and rewrite the equation as a·|x − h| + k.
Show answer
Factor the inside: |2x − 8| = |2(x − 4)| = 2|x − 4|. The vertex is at (4, 1), not (8, 1), because the shift is found after factoring out the coefficient of x. The equation is g(x) = 2|x − 4| + 1.