Skip to content
Family Table Math

Composition, Inverses, and Transformations

Composition gives you a new way to look at two ideas you already know. An inverse is the function that, composed with ff, takes every number back to where it started. And every transformation you’ve done, like stretches and shifts, is really a composition with a simple linear function. Trig functions here use radians, and log⁡x\log x means log⁡10x\log_{10} x.

If ff sends aa to bb, its inverse sends bb back to aa. Put the two machines in a row and the number comes out unchanged:

a  →  f    b  →  f−1    aa \;\xrightarrow{\;f\;}\; b \;\xrightarrow{\;f^{-1}\;}\; a

So composing a function with its inverse, in either order, maps every number onto itself:

f−1(f(x))=x   for every x in the domain of ff(f−1(x))=x   for every x in the domain of f−1f^{-1}\big(f(x)\big) = x \;\text{ for every } x \text{ in the domain of } f \qquad f\big(f^{-1}(x)\big) = x \;\text{ for every } x \text{ in the domain of } f^{-1}

For example, if f(2)=9f(2) = 9, then f−1(f(2))=f−1(9)=2f^{-1}(f(2)) = f^{-1}(9) = 2.

Two functions ff and gg are inverses of each other exactly when

f(g(x))=xandg(f(x))=xf\big(g(x)\big) = x \quad\text{and}\quad g\big(f(x)\big) = x

for every xx in the right domains. You need to check both orders.

The identities only hold on the right domains, and this matters when a domain has been restricted.

  • f(x)=x2f(x) = x^2 with x≥0x \ge 0 has inverse f−1(x)=xf^{-1}(x) = \sqrt{x}. Then x2=x\sqrt{x^2} = x only for x≥0x \ge 0. For every real xx, x2=∣x∣\sqrt{x^2} = \lvert x \rvert: for example, (−3)2=3\sqrt{(-3)^2} = 3, not −3-3.
  • f(x)=10xf(x) = 10^x and f−1(x)=log⁡xf^{-1}(x) = \log x. Then log⁡(10x)=x\log(10^x) = x for every real xx, but 10log⁡x=x10^{\log x} = x only for x>0x \gt 0, since log⁡x\log x needs a positive input.

Let g(x)=A(x+B)g(x) = A(x + B), a linear function. Composing it with ff in the two different orders gives the two kinds of transformations.

gg on the inside: horizontal changes.

f(g(x))=f(A(x+B))f\big(g(x)\big) = f\big(A(x + B)\big)

This is y=f(k(x−d))y = f(k(x - d)) with k=Ak = A and d=−Bd = -B: a horizontal stretch or compression by a factor of 1∣A∣\dfrac{1}{\lvert A \rvert} (and a reflection in the yy-axis if A<0A \lt 0), then a translation BB units left (right if B<0B \lt 0).

gg on the outside: vertical changes.

g(f(x))=A(f(x)+B)=Af(x)+ABg\big(f(x)\big) = A\big(f(x) + B\big) = A f(x) + AB

This is a vertical stretch by a factor of ∣A∣\lvert A \rvert (and a reflection in the xx-axis if A<0A \lt 0), then a translation of ABAB units up. Notice that the vertical shift is ABAB, not BB: the +B+B happens first, and then it gets stretched too.

So “inside” changes act on xx (horizontally), and “outside” changes act on yy (vertically), just as in combined transformations.

With g(x)=2(x−1)g(x) = 2(x - 1), so A=2A = 2 and B=−1B = -1:

f(x)f(x)f(g(x))f(g(x)): horizontalg(f(x))g(f(x)): vertical
x2x^2(2(x−1))2=4(x−1)2\big(2(x - 1)\big)^2 = 4(x - 1)^2: vertex (1,0)(1, 0)2(x2−1)=2x2−22(x^2 - 1) = 2x^2 - 2: vertex (0,−2)(0, -2)
sin⁡x\sin xsin⁡(2(x−1))\sin\big(2(x - 1)\big): period π\pi, shifted 11 right2(sin⁡x−1)=2sin⁡x−22(\sin x - 1) = 2\sin x - 2: amplitude 22, axis y=−2y = -2
log⁡x\log xlog⁡(2(x−1))\log\big(2(x - 1)\big): asymptote x=1x = 12(log⁡x−1)=2log⁡x−22(\log x - 1) = 2\log x - 2: asymptote x=0x = 0
The dashed parent y = x^2, the graph of f(g(x)) = 4(x - 1)^2 with vertex (1, 0), and the graph of g(f(x)) = 2x^2 - 2 with vertex (0, -2). −2 2 4 2 4 6 (1, 0) (0, −2) y = f(g(x)) = 4(x − 1)² y = g(f(x)) = 2x² − 2
For f(x)=x2f(x) = x^2 and g(x)=2(x−1)g(x) = 2(x - 1): f(g(x))f(g(x)) moves the vertex sideways, while g(f(x))g(f(x)) moves it down.

Example 1: Numbers going in and coming back

Section titled “Example 1: Numbers going in and coming back”

Let f(x)=3x−7f(x) = 3x - 7.

  • (a) Find f−1(x)f^{-1}(x).
  • (b) Evaluate f−1(f(4))f^{-1}(f(4)) and f(f−1(−1))f(f^{-1}(-1)) step by step.
  • (c) Show that f−1(f(x))=xf^{-1}(f(x)) = x and f(f−1(x))=xf(f^{-1}(x)) = x for all xx.

Solution.

(a) Swap xx and yy in y=3x−7y = 3x - 7: x=3y−7x = 3y - 7, so y=x+73y = \dfrac{x + 7}{3}. That is, f−1(x)=x+73f^{-1}(x) = \dfrac{x + 7}{3}.

(b) f(4)=12−7=5f(4) = 12 - 7 = 5, and f−1(5)=123=4f^{-1}(5) = \dfrac{12}{3} = 4. So f−1(f(4))=4f^{-1}(f(4)) = 4.

f−1(−1)=63=2f^{-1}(-1) = \dfrac{6}{3} = 2, and f(2)=6−7=−1f(2) = 6 - 7 = -1. So f(f−1(−1))=−1f(f^{-1}(-1)) = -1.

Each number came back to where it started.

(c)

f−1(f(x))=(3x−7)+73=3x3=xf^{-1}\big(f(x)\big) = \frac{(3x - 7) + 7}{3} = \frac{3x}{3} = x f(f−1(x))=3(x+73)−7=(x+7)−7=xf\big(f^{-1}(x)\big) = 3\left(\frac{x + 7}{3}\right) - 7 = (x + 7) - 7 = x

Example 2: Checking inverses by composition

Section titled “Example 2: Checking inverses by composition”

Show that f(x)=x−1x+2f(x) = \dfrac{x - 1}{x + 2} and g(x)=2x+11−xg(x) = \dfrac{2x + 1}{1 - x} are inverses of each other.

Solution. Compose in both orders. Each time, simplify the top and the bottom over a common denominator.

f(g(x))=2x+11−x−12x+11−x+2=2x+1−(1−x)1−x2x+1+2(1−x)1−x=3x3=x\begin{aligned} f\big(g(x)\big) &= \frac{\dfrac{2x + 1}{1 - x} - 1}{\dfrac{2x + 1}{1 - x} + 2} = \frac{\dfrac{2x + 1 - (1 - x)}{1 - x}}{\dfrac{2x + 1 + 2(1 - x)}{1 - x}} \\ &= \frac{3x}{3} = x \end{aligned} g(f(x))=2(x−1x+2)+11−x−1x+2=2(x−1)+(x+2)x+2(x+2)−(x−1)x+2=3x3=x\begin{aligned} g\big(f(x)\big) &= \frac{2\left(\dfrac{x - 1}{x + 2}\right) + 1}{1 - \dfrac{x - 1}{x + 2}} = \frac{\dfrac{2(x - 1) + (x + 2)}{x + 2}}{\dfrac{(x + 2) - (x - 1)}{x + 2}} \\ &= \frac{3x}{3} = x \end{aligned}

Both compositions give xx (for x≠−2x \ne -2 in g(f(x))g(f(x)) and x≠1x \ne 1 in f(g(x))f(g(x))), so ff and gg are inverses.

Quick check: f(4)=36=0.5f(4) = \dfrac{3}{6} = 0.5 and g(0.5)=20.5=4g(0.5) = \dfrac{2}{0.5} = 4. ✓

Let f(x)=x2−4f(x) = x^2 - 4 for x≥0x \ge 0, with inverse f−1(x)=x+4f^{-1}(x) = \sqrt{x + 4}.

  • (a) Simplify f−1(f(x))f^{-1}(f(x)) and f(f−1(x))f(f^{-1}(x)), and state where each equals xx.
  • (b) What goes wrong if you put x=−3x = -3 into the formula for f−1(f(x))f^{-1}(f(x))?

Solution.

(a)

f−1(f(x))=(x2−4)+4=x2=∣x∣f^{-1}\big(f(x)\big) = \sqrt{(x^2 - 4) + 4} = \sqrt{x^2} = \lvert x \rvert

This equals xx for x≥0x \ge 0, which is exactly the domain of ff. ✓

f(f−1(x))=(x+4)2−4=(x+4)−4=xf\big(f^{-1}(x)\big) = \left(\sqrt{x + 4}\right)^2 - 4 = (x + 4) - 4 = x

This works for x≥−4x \ge -4, the domain of f−1f^{-1} (and the range of ff). ✓

(b) (−3)2−4=5(-3)^2 - 4 = 5 and 5+4=3\sqrt{5 + 4} = 3, so you get 33, not −3-3. That’s not a contradiction: −3-3 isn’t in the restricted domain of ff, so the identity was never promised for it.

Example 4: Transformations as compositions

Section titled “Example 4: Transformations as compositions”

Let g(x)=3(x−2)g(x) = 3(x - 2). For f(x)=x2f(x) = x^2, f(x)=sin⁡xf(x) = \sin x and f(x)=log⁡xf(x) = \log x, find f(g(x))f(g(x)) and g(f(x))g(f(x)) and describe each as a transformation of ff.

Solution. Here A=3A = 3 and B=−2B = -2.

f(x)=x2f(x) = x^2.

  • f(g(x))=(3(x−2))2=9(x−2)2f(g(x)) = \big(3(x - 2)\big)^2 = 9(x - 2)^2: a horizontal compression by a factor of 13\tfrac{1}{3}, then a translation 22 units right. Vertex (2,0)(2, 0).
  • g(f(x))=3(x2−2)=3x2−6g(f(x)) = 3(x^2 - 2) = 3x^2 - 6: a vertical stretch by a factor of 33, then a translation AB=−6AB = -6, so 66 units down. Vertex (0,−6)(0, -6).

f(x)=sin⁡xf(x) = \sin x.

  • f(g(x))=sin⁡(3(x−2))f(g(x)) = \sin\big(3(x - 2)\big): period 2π3\tfrac{2\pi}{3}, translated 22 units right. The range stays {y∈R∣−1≤y≤1}\{y \in \mathbb{R} \mid -1 \le y \le 1\}.
  • g(f(x))=3(sin⁡x−2)=3sin⁡x−6g(f(x)) = 3(\sin x - 2) = 3\sin x - 6: amplitude 33, axis y=−6y = -6, period still 2π2\pi. The range is {y∈R∣−9≤y≤−3}\{y \in \mathbb{R} \mid -9 \le y \le -3\}.

f(x)=log⁡xf(x) = \log x.

  • f(g(x))=log⁡(3(x−2))f(g(x)) = \log\big(3(x - 2)\big): compressed horizontally by 13\tfrac{1}{3} and shifted 22 right. The domain is {x∈R∣x>2}\{x \in \mathbb{R} \mid x \gt 2\} and the vertical asymptote is x=2x = 2. By the laws of logarithms, this also equals log⁡3+log⁡(x−2)\log 3 + \log(x - 2): for logarithms, a horizontal compression is the same as a vertical shift (up log⁡3≈0.48\log 3 \approx 0.48).
  • g(f(x))=3(log⁡x−2)=3log⁡x−6g(f(x)) = 3(\log x - 2) = 3\log x - 6: stretched vertically by 33 and shifted 66 down. The domain is still {x∈R∣x>0}\{x \in \mathbb{R} \mid x \gt 0\}, with asymptote x=0x = 0. It passes through (1,−6)(1, -6) and (10,−3)(10, -3).

In every case, gg on the inside changed things horizontally, and gg on the outside changed things vertically.

Checking only one composition. f(g(x))=xf(g(x)) = x alone isn’t enough to prove that ff and gg are inverses in general. Check both orders.

Ignoring the domain. x2\sqrt{x^2} is ∣x∣\lvert x \rvert, not xx. The identity f−1(f(x))=xf^{-1}(f(x)) = x only holds for xx in the domain of ff, so a restricted domain matters.

Assuming 10log⁡x=x10^{\log x} = x for every xx. 10log⁡x=x10^{\log x} = x needs x>0x \gt 0; for x=−5x = -5, log⁡(−5)\log(-5) doesn’t exist. (But log⁡(10x)=x\log(10^x) = x works for every real xx.)

Getting the direction of the horizontal shift wrong. f(A(x+B))f(A(x + B)) shifts the graph BB units left, the opposite of the sign you see. sin⁡(3(x−2))\sin\big(3(x - 2)\big) moves 22 units right.

Forgetting that the vertical shift gets stretched. g(f(x))=A(f(x)+B)g(f(x)) = A(f(x) + B) moves the graph by ABAB, not BB. With g(x)=3(x−2)g(x) = 3(x - 2), g(f(x))=3f(x)−6g(f(x)) = 3f(x) - 6, a shift of 66 down, not 22 down.

Confusing f−1f^{-1} with 1f\dfrac{1}{f}. f−1(f(x))=xf^{-1}(f(x)) = x is about undoing. 1f(x)⋅f(x)=1\dfrac{1}{f(x)} \cdot f(x) = 1 is a different fact about reciprocals.

1. (Warm-up) ff is a function with an inverse, and f(5)=12f(5) = 12. Find:

  • (a) f−1(f(5))f^{-1}(f(5))
  • (b) f(f−1(12))f(f^{-1}(12))
  • (c) f−1(12)f^{-1}(12)
Solution

(a) f(5)=12f(5) = 12, then f−1(12)=5f^{-1}(12) = 5. So f−1(f(5))=5f^{-1}(f(5)) = 5.

(b) f−1(12)=5f^{-1}(12) = 5, then f(5)=12f(5) = 12. So f(f−1(12))=12f(f^{-1}(12)) = 12.

(c) f−1(12)=5f^{-1}(12) = 5.

2. (Warm-up) Show that f(x)=4x+1f(x) = 4x + 1 and g(x)=x−14g(x) = \dfrac{x - 1}{4} are inverses by composition.

Solutionf(g(x))=4(x−14)+1=x−1+1=xf\big(g(x)\big) = 4\left(\frac{x - 1}{4}\right) + 1 = x - 1 + 1 = xg(f(x))=(4x+1)−14=4x4=xg\big(f(x)\big) = \frac{(4x + 1) - 1}{4} = \frac{4x}{4} = x

Both give xx, so they’re inverses.

3. (Warm-up) Simplify each expression.

  • (a) 10log⁡710^{\log 7}
  • (b) log⁡(103.2)\log\left(10^{3.2}\right)
  • (c) (11)2\left(\sqrt{11}\right)^2
Solution

10x10^x and log⁡x\log x are inverses, and so are x2x^2 (for x≥0x \ge 0) and x\sqrt{x}. Each pair cancels:

(a) 77 (b) 3.23.2 (c) 1111

4. (Core) Are f(x)=2x−6f(x) = 2x - 6 and g(x)=x2−6g(x) = \dfrac{x}{2} - 6 inverses? If not, find the correct inverse of ff.

Solutionf(g(x))=2(x2−6)−6=x−12−6=x−18f\big(g(x)\big) = 2\left(\frac{x}{2} - 6\right) - 6 = x - 12 - 6 = x - 18

That’s not xx, so they are not inverses. To find f−1f^{-1}: x=2y−6x = 2y - 6 gives y=x+62=x2+3y = \dfrac{x + 6}{2} = \dfrac{x}{2} + 3.

Check: f(x2+3)=x+6−6=xf\left(\dfrac{x}{2} + 3\right) = x + 6 - 6 = x ✓ and 2x−62+3=x−3+3=x\dfrac{2x - 6}{2} + 3 = x - 3 + 3 = x. ✓

5. (Core) Show that f(x)=1x−3f(x) = \dfrac{1}{x - 3} and g(x)=1x+3g(x) = \dfrac{1}{x} + 3 are inverses, and state the domain of each.

Solutionf(g(x))=1(1x+3)−3=1  1x  =xf\big(g(x)\big) = \frac{1}{\left(\frac{1}{x} + 3\right) - 3} = \frac{1}{\;\frac{1}{x}\;} = xg(f(x))=1  1x−3  +3=(x−3)+3=xg\big(f(x)\big) = \frac{1}{\;\frac{1}{x - 3}\;} + 3 = (x - 3) + 3 = x

Both give xx, so they’re inverses. Domain of ff: {x∈R∣x≠3}\{x \in \mathbb{R} \mid x \ne 3\}. Domain of gg: {x∈R∣x≠0}\{x \in \mathbb{R} \mid x \ne 0\}. (Each domain is the other’s range.)

6. (Core) Let f(x)=x2+2f(x) = x^2 + 2 for x≤0x \le 0.

  • (a) Find f−1(x)f^{-1}(x) and its domain.
  • (b) Verify that f−1(f(x))=xf^{-1}(f(x)) = x and f(f−1(x))=xf(f^{-1}(x)) = x on the right domains.
Solution

(a) Swap: x=y2+2x = y^2 + 2, so y=±x−2y = \pm\sqrt{x - 2}. The range of f−1f^{-1} must be the domain of ff, y≤0y \le 0, so take the negative root:

f−1(x)=−x−2,{x∈R∣x≥2}f^{-1}(x) = -\sqrt{x - 2}, \qquad \{x \in \mathbb{R} \mid x \ge 2\}

(b) For x≤0x \le 0:

f−1(f(x))=−(x2+2)−2=−x2=−∣x∣=xf^{-1}\big(f(x)\big) = -\sqrt{(x^2 + 2) - 2} = -\sqrt{x^2} = -\lvert x \rvert = x

The last step works because x≤0x \le 0, so ∣x∣=−x\lvert x \rvert = -x. For x≥2x \ge 2:

f(f−1(x))=(−x−2)2+2=(x−2)+2=xf\big(f^{-1}(x)\big) = \left(-\sqrt{x - 2}\right)^2 + 2 = (x - 2) + 2 = x

7. (Core) Let f(x)=sin⁡xf(x) = \sin x and g(x)=2(x+1)g(x) = 2(x + 1). Find f(g(x))f(g(x)) and g(f(x))g(f(x)), and describe each as a transformation of y=sin⁡xy = \sin x. State the range of each.

Solution

f(g(x))=sin⁡(2(x+1))f(g(x)) = \sin\big(2(x + 1)\big): a horizontal compression by a factor of 12\tfrac{1}{2} (period π\pi), then a translation 11 unit left. The range is {y∈R∣−1≤y≤1}\{y \in \mathbb{R} \mid -1 \le y \le 1\}.

g(f(x))=2(sin⁡x+1)=2sin⁡x+2g(f(x)) = 2(\sin x + 1) = 2\sin x + 2: a vertical stretch by a factor of 22, then a translation 22 units up. The range is {y∈R∣0≤y≤4}\{y \in \mathbb{R} \mid 0 \le y \le 4\}.

8. (Challenge) Let f(x)=log⁡xf(x) = \log x and g(x)=10(x+2)g(x) = 10(x + 2).

  • (a) Find f(g(x))f(g(x)), and use a law of logarithms to show it is a vertical translation of y=log⁡(x+2)y = \log(x + 2).
  • (b) Find g(f(x))g(f(x)) and state its domain.
Solution

(a)

f(g(x))=log⁡(10(x+2))=log⁡10+log⁡(x+2)=1+log⁡(x+2)f\big(g(x)\big) = \log\big(10(x + 2)\big) = \log 10 + \log(x + 2) = 1 + \log(x + 2)

So y=log⁡(10(x+2))y = \log(10(x + 2)), which is y=log⁡xy = \log x compressed horizontally by a factor of 110\tfrac{1}{10} and then shifted 22 left, is the same graph as y=log⁡(x+2)y = \log(x + 2) translated up 11 unit. The domain is {x∈R∣x>−2}\{x \in \mathbb{R} \mid x \gt -2\}.

(b) g(f(x))=10(log⁡x+2)=10log⁡x+20g(f(x)) = 10(\log x + 2) = 10\log x + 20. The domain is {x∈R∣x>0}\{x \in \mathbb{R} \mid x \gt 0\}.

9. (Challenge) Let f(x)=x2f(x) = x^2.

  • (a) Find all linear functions g(x)=A(x+B)g(x) = A(x + B) with f(g(x))=9x2−12x+4f(g(x)) = 9x^2 - 12x + 4.
  • (b) Show that h(x)=x+5x−1h(x) = \dfrac{x + 5}{x - 1} is its own inverse by finding h(h(x))h(h(x)).
Solution

(a) 9x2−12x+4=(3x−2)29x^2 - 12x + 4 = (3x - 2)^2, so we need (g(x))2=(3x−2)2\big(g(x)\big)^2 = (3x - 2)^2. That means g(x)=3x−2g(x) = 3x - 2 or g(x)=−(3x−2)=−3x+2g(x) = -(3x - 2) = -3x + 2. In the form A(x+B)A(x + B):

g(x)=3(x−23)org(x)=−3(x−23)g(x) = 3\left(x - \tfrac{2}{3}\right) \qquad\text{or}\qquad g(x) = -3\left(x - \tfrac{2}{3}\right)

(The second one includes a reflection in the yy-axis, which doesn’t change the even function x2x^2.)

(b) Multiply the top and bottom by (x−1)(x - 1):

h(h(x))=x+5x−1+5x+5x−1−1=(x+5)+5(x−1)(x+5)−(x−1)=6x6=xh\big(h(x)\big) = \frac{\dfrac{x + 5}{x - 1} + 5}{\dfrac{x + 5}{x - 1} - 1} = \frac{(x + 5) + 5(x - 1)}{(x + 5) - (x - 1)} = \frac{6x}{6} = x

So h(h(x))=xh(h(x)) = x for x≠1x \ne 1, which means hh undoes itself: h−1=hh^{-1} = h.