Algebra & functions · Function transformations

Function transformations

Shifts, stretches and reflections turn y = f(x) into y = a·f(b(x − h)) + k. Adjust the parameters and follow how the curve and a point on it move.

01

Function transformations in this visualization

A transformation of the graph of a function shifts it, stretches or compresses it, or reflects it. With four parameters the transformed function is g(x)=a f(b(x−h))+kg(x) = a\,f(b(x - h)) + k, where b≠0b \ne 0. By default this page uses a polyline ff with no symmetry, so every transformation shows; seven common parent functions are there too: x2x^2, x3x^3, x\sqrt{x}, 1/x1/x, ∣x∣|x|, 2x2^x and sin⁡x\sin x.

The dashed curve is the parent graph y=f(x)y = f(x), the solid curve is y=g(x)y = g(x). A point P = (x0,f(x0))(x_0, f(x_0)) on the parent and its image P′ on gg are joined by red arrows, one for each step. Every point of the graph moves by the same rule:

Point map
(x,y)↦(xb+h, a y+k)(x, y) \mapsto \left(\frac{x}{b} + h,\ a\,y + k\right)

Why the inside acts the opposite way: a point (x,y)(x, y) lies on the graph of gg when x0=b(x−h)x_0 = b(x - h) is an input of ff and y=a f(x0)+ky = a\,f(x_0) + k. Solving for the new x-coordinate gives x=x0/b+hx = x_0/b + h: the shift hh is added, but the old coordinate is divided by bb. So h=2h = 2 moves the graph right although the formula shows x−2x - 2, and b=2b = 2 halves its width. The outside parameters act on the output directly.

Also written y=f(x+φ)y = f(x + \varphi): for φ>0\varphi > 0 the graph moves φ\varphi to the left, which is h=−φh = -\varphi here. The sinusoid y=Asin⁡(ωx+φ)+ky = A\sin(\omega x + \varphi) + k is a special case of this page too: a=Aa = A, b=ωb = \omega, h=−φ/ωh = -\varphi/\omega.

02

The order of the steps

The red button builds gg from ff step by step: inside the bracket (horizontal) first, then outside (vertical). Inside there are two ways, chosen with the lever beside the button. Scale first: divide the x-coordinates by bb (a horizontal stretch or compression relative to the y-axis, with a reflection across it when b<0b < 0), then add hh. Shift first: add bhbh to the x-coordinates, then divide them by bb — which divides the shift too, leaving exactly hh. Outside: multiply the y-coordinates by aa (a vertical stretch or compression relative to the x-axis, with a reflection across it when a<0a < 0), then add kk. Steps whose parameter changes nothing are skipped.

Both ways end on the same gg. After each run the graphs on the way stay, faint, until a parameter changes; throw the lever and press again, and the two ways lie side by side.

In each direction the stretch comes before the shift when the shift is written as hh or kk: shifting by hh first and then dividing the x-coordinates by bb divides the shift as well, and the graph ends up shifted by h/bh/b. (Shifting first works if the shift is bhbh — the lever’s Shift side.) Horizontal and vertical steps do not affect each other, so either direction may go first.

03

Easy to misread

  • (2x−6)2=(2(x−3))2(2x - 6)^2 = (2(x - 3))^2: the graph of x2x^2 is squeezed to half its width, then shifted 3 to the right — not 6. Factor bb out first to read the shift.
  • b=2b = 2 compresses the graph to half its width; b=12b = \tfrac12 stretches it to twice its width. For aa it is the other way round: a=2a = 2 doubles the heights.
  • bb cannot be 0 on this page: the point map divides by bb (and f(0⋅x)=f(0)f(0 \cdot x) = f(0) is not even defined for 1/x1/x). a=0a = 0 is allowed and flattens the graph onto y=ky = k over the domain of f(b(x−h))f(b(x - h)): a ray for x\sqrt{x}, the line without the point x=hx = h for 1/x1/x (which then has no vertical asymptote).
  • For an even function (x2x^2, ∣x∣|x|), b=−1b = -1 changes nothing, because f(−x)=f(x)f(-x) = f(x). For an odd function (x3x^3, 1/x1/x, sin⁡x\sin x), a=−1a = -1 and b=−1b = -1 give the same graph, because −f(x)=f(−x)-f(x) = f(-x). On ∣x∣|x|, ∣2x∣=2∣x∣|2x| = 2|x|: a horizontal squeeze and a vertical stretch draw the same curve, and only the point P tells them apart (highlight 7). The polyline ff has none of these coincidences.
  • Asymptotes and domains move with the graph: for a≠0a \ne 0 the asymptotes of 1/x1/x move to x=hx = h and y=ky = k, and the domain of b(x−h)\sqrt{b(x - h)} is where b(x−h)≥0b(x - h) \ge 0.
  • The point P can be dragged along the parent graph (or P′ along gg); grab gg anywhere else to slide the whole graph, and the faders for hh and kk follow.
04

Related