Interactive tool

Function transformation explorer

Shift, stretch and reflect a parent graph with four sliders, and follow its key points, its formula, its domain and its range as they move.

A whole family of graphs, such as every parabola with a vertical axis, comes from one parent graph by shifts, stretches and reflections. Pick a parent function ff and set the four numbers in

g(x)=a f(b(x−h))+k.g(x) = a\,f\big(b(x - h)\big) + k.

The faded curve is ff and the bold curve is gg. Arrows join three key points of ff to the points where they land on gg, so every change has a visible cause. Drag the ring on the graph to move hh and kk together, and use the play button to watch gg being built from ff one step at a time.

Parent function f

f of x equals x squared

g of x equals 2 times the square of the quantity x minus 2, minus 3

−7−6−5−4−3−2−11234567−5−4−3−2−112345xyABCA′B′C′
  • Parent f
  • New function g
  • Where each key point moves
Inside f, acting on x
1

Negative values reflect across the y-axis

2

Positive values move right

Outside f, acting on y
2

Negative values reflect across the x-axis

−3

Positive values move up

Steps from f to g, in order

  1. No horizontal stretch or reflection
  2. Shift right by 2
  3. Stretch vertically away from the x-axis by the factor 2
  4. Shift down by 3

Each point (x, y) of f moves to

(x + 2, 2y − 3)

f and g side by side
Featurefg
Domain(−∞, ∞)(−∞, ∞)
Range[0, ∞)[−3, ∞)
Point A(−1, 1)(1, −1)
Point B(0, 0)(2, −3)
Point C(1, 1)(3, −1)

The sliders for aa and bb jump from −0.25-0.25 straight to 0.250.25. With a=0a = 0 or b=0b = 0 the graph would collapse onto a horizontal line, or vanish when f(0)f(0) is undefined, so gg would no longer be a copy of ff.

Things to try

  • Choose x2x^2, set a=1a = 1, b=1b = 1 and k=0k = 0, and move hh to 33. The formula shows (x−3)2(x - 3)^2 with a minus sign, yet the vertex moves right to (3,0)(3, 0), because g(3)=f(0)g(3) = f(0).
  • Keep x2x^2 and compare b=2b = 2 with a=4a = 4, each time with the other factor at 11. The two graphs are identical, since (2x)2=4x2(2x)^2 = 4x^2. The same happens with ∣x∣\lvert x \rvert for b=2b = 2 and a=2a = 2, and with x\sqrt{x} for b=4b = 4 and a=2a = 2.
  • Choose x\sqrt{x} and make bb negative. The graph flips across the vertical line x=hx = h and the domain turns from [h,∞)[h, \infty) into (−∞,h](-\infty, h]. Make aa negative instead and the graph flips across the line y=ky = k, so the range turns from [k,∞)[k, \infty) into (−∞,k](-\infty, k] while the domain stays where it was.
  • Choose 1/x1/x and drag the ring around. The dashed asymptotes x=hx = h and y=ky = k travel with it, and the domain and the range leave out exactly hh and kk.
  • Choose 2x2^x and set a=−1a = -1. The curve drops below its asymptote and the range changes from (k,∞)(k, \infty) to (−∞,k)(-\infty, k). With ln⁡x\ln x and b=−1b = -1 it is the domain that flips, to (−∞,h)(-\infty, h).
  • Choose sin⁡x\sin x and try b=2b = 2 and then b=0.5b = 0.5. The period 2π2\pi becomes π\pi and then 4π4\pi, while the range is always [k−∣a∣,k+∣a∣][k - \lvert a \rvert, k + \lvert a \rvert].
  • With x2x^2, set a=1a = 1, b=2b = 2, h=3h = 3 and k=0k = 0 and play the steps. The vertex BB stays at the origin during the compression and then moves right to (3,0)(3, 0). Had the shift come first, the compression would have pulled it back to (1.5,0)(1.5, 0).
  • Choose x2x^2 and switch bb between 11 and −1-1. The graph does not change, but the images A′A' and C′C' trade places, because x2x^2 is even and f(−x)=f(x)f(-x) = f(x). With x3x^3 the graph stays the same only when aa and bb change sign together, because x3x^3 is odd and f(−x)=−f(x)f(-x) = -f(x).

What you are seeing

Each point (x,y)(x, y) on the graph of ff lands at

(xb+h,  ay+k)\left(\frac{x}{b} + h,\; ay + k\right)

on the graph of gg. To check, put the new first coordinate into gg.

g(xb+h)=a f(b(xb+h−h))+k=a f(x)+k\begin{aligned} g\left(\frac{x}{b} + h\right) &= a\,f\left(b\left(\frac{x}{b} + h - h\right)\right) + k \\[0.8em] &= a\,f(x) + k \end{aligned}

The explorer draws gg exactly this way, by moving every point of ff, and the readout under the graph spells out the rule with the current numbers. The table next to it applies the rule to the key points AA, BB and CC, with exact values.

The order of the steps

The second coordinate is multiplied by aa and then shifted by kk, the same order in which a f(…)+ka\,f(\ldots) + k is worked out. The first coordinate is divided by bb and then shifted by hh. So the explorer lists the steps in this order.

  1. Stretch or compress horizontally by the factor 1∣b∣\frac{1}{\lvert b \rvert}, and reflect across the yy-axis when b<0b < 0.
  2. Shift horizontally by hh.
  3. Stretch or compress vertically by the factor ∣a∣\lvert a \rvert, and reflect across the xx-axis when a<0a < 0.
  4. Shift vertically by kk.

Horizontal and vertical steps do not affect each other, so the two pairs could come in either order. Within each pair the order matters. Compressing y=x2y = x^2 by the factor 12\frac{1}{2} and then shifting it right by 33 gives

y=(2(x−3))2,y = \big(2(x - 3)\big)^2,

which takes the point (2,4)(2, 4) to (4,4)(4, 4). Shifting first and then compressing gives a different parabola,

y=(2x−3)2=(2(x−1.5))2,y = (2x - 3)^2 = \big(2(x - 1.5)\big)^2,

with its vertex at (1.5,0)(1.5, 0) instead of (3,0)(3, 0). That is why an input such as 2x−62x - 6 should be factored as 2(x−3)2(x - 3) before the shift is read off.

Composition gives another way to see the order. Write u(x)=b(x−h)u(x) = b(x - h) for the inside and v(y)=ay+kv(y) = ay + k for the outside, so that

g=v∘f∘u.g = v \circ f \circ u.

An input passes through uu first, then ff, then vv. The lesson on function composition explains this way of building functions in general.

Why the inside acts the opposite way

The outside numbers act on the outputs of ff directly. Adding kk moves the graph up by kk, and the factor aa multiplies every height by aa. The inside numbers act on the input before ff sees it. To get the output that ff gives at some input uu, the function gg needs an xx with b(x−h)=ub(x - h) = u, and solving for xx gives

x=ub+h.x = \frac{u}{b} + h.

So subtracting hh inside moves the graph right by hh, and multiplying by bb inside scales it horizontally by the factor 1b\frac{1}{b}, which is a compression when b>1b > 1. Each inside change shows up on the graph undone. In sin⁡(2x)\sin(2x) the input runs twice as fast, so a full wave fits into half the distance.

Domain, range and asymptotes

The domain of gg is the set of all xx for which b(x−h)b(x - h) is an allowed input of ff. For x\sqrt{x} that means b(x−h)≥0b(x - h) \ge 0, so the domain is [h,∞)[h, \infty) when b>0b > 0 and (−∞,h](-\infty, h] when b<0b < 0.

The range of gg is the set of all values ay+kay + k with yy in the range of ff. For x2x^2, ∣x∣\lvert x \rvert and x\sqrt{x} it is [k,∞)[k, \infty) when a>0a > 0 and (−∞,k](-\infty, k] when a<0a < 0. Horizontal steps never change the range, and vertical steps never change the domain.

The vertical asymptote x=0x = 0 of 1/x1/x and ln⁡x\ln x moves to x=hx = h, and the horizontal asymptote y=0y = 0 of 1/x1/x and 2x2^x moves to y=ky = k. They move like any other part of the graph, by the same rule as the points.

The lessons on shifts and reflections and on stretches and compressions work through these rules with more examples, and the lesson on even and odd functions explains the symmetry behind the last thing to try. The same numbers come back in the vertex form of a parabola in Quadratic Functions and Vertex Form, in the shifted curves of Graphs of Exponential and Logarithmic Functions and as the amplitude, period and phase shift of a wave in Amplitude, Period, and Phase Shift. The rules are also collected on the precalculus reference sheet. Every lesson is listed on the Precalculus course page, and the video lessons are coming soon. For test preparation, the SAT Math lessons Shifting, Reflecting and Stretching Graphs and Quadratic Graphs and Their Forms apply the same rules.