Unit 10 · Lesson 4 of 4

Composition and inverse functions

About 25 minutes · 5 steps · one idea: chaining functions, and undoing them

You'll be able to: compute \(f(g(x))\) and \(f(g(2))\), and find the inverse \(f^{-1}(x)\) of a one-to-one function by swapping \(x\) and \(y\).

  1. 1 Warm-up
  2. 2 The idea
  3. 3 Examples
  4. 4 Practice
  5. 5 Wrap-up

Step 1 of 5Warm-up

Two quick questions from earlier lessons. Answer from memory first. Pulling it out of your head is what makes it stick.

What is the vertex of \(y = -(x - 2)^2 + 6\)? Type it as a point.

Inside: \(x - 2\) is zero at \(x = 2\), so the graph of \(x^2\) moves right 2.

Outside: \(+6\) moves it up 6. (The minus sign only flips it.) Vertex: \((2, 6)\).

Solve \(y = 3x - 7\) for \(x\). Type only the right side of \(x = \) ...

Add 7 to both sides: \(y + 7 = 3x\).

Divide by 3: \(x = \dfrac{y + 7}{3}\).

Step 2 of 5The idea

Composition means feeding one function's output into another. \((f \circ g)(x)\) is read "f of g of x" and means \(f(g(x))\). Work from the inside out: do \(g\) first, then \(f\). See composition in the glossary.

Order matters: \(f(g(x))\) and \(g(f(x))\) are usually different.

An inverse function \(f^{-1}\) undoes \(f\). If \(f(2) = 7\), then \(f^{-1}(7) = 2\). The inputs and outputs trade places, so in the formula, \(x\) and \(y\) trade places.

Only one-to-one functions have inverses: different inputs must give different outputs. On a graph, no horizontal line may cross it twice. \(f(x) = x^2\) fails, since \(f(2) = f(-2) = 4\), so "undo 4" has two answers.

Composition: \((f \circ g)(x) = f(g(x))\). Put all of \(g(x)\), in parentheses, in place of each \(x\) in \(f\).

Finding \(f^{-1}\): (1) write \(y = f(x)\); (2) swap \(x\) and \(y\); (3) solve for \(y\); (4) that \(y\) is \(f^{-1}(x)\).

Check: \(f(f^{-1}(x))\) should simplify to exactly \(x\).

Why this shows up on the placement test: composition and inverses are College Algebra topics, so the placement test uses them to sort students between MATH 1010 and MATH 1050.

Step 3 of 5Worked examples

Example 1: \(f(x) = 2x + 1\) and \(g(x) = x^2 - 3\)

Find \((f \circ g)(2)\), then \((g \circ f)(x)\).

  1. Inside first: \(g(2) = 2^2 - 3 = 1\).
  2. Then \(f\) of that: \(f(1) = 2(1) + 1 = 3\). So \((f \circ g)(2) = 3\).
  3. For \((g \circ f)(x) = g(f(x))\), put \((2x + 1)\) in place of \(x\) in \(g\): \((2x + 1)^2 - 3\).
  4. Expand: \(4x^2 + 4x + 1 - 3 = 4x^2 + 4x - 2\). \((2x + 1)^2 = 4x^2 + 4x + 1\) (Lesson 26).

Example 2: find the inverse of \(f(x) = 3x - 4\)

  1. Write \(y = 3x - 4\). It is a non-flat line, so it is one-to-one.
  2. Swap \(x\) and \(y\): \(x = 3y - 4\).
  3. Solve for \(y\): add 4, \(x + 4 = 3y\); divide by 3, \(y = \dfrac{x + 4}{3}\).
  4. So \(f^{-1}(x) = \dfrac{x + 4}{3}\).
  5. Check: \(f\left(\dfrac{x + 4}{3}\right) = 3 \cdot \dfrac{x + 4}{3} - 4 = x + 4 - 4 = x\). It works.
\(f\) (steep line) and \(f^{-1}\) (gentle line) are mirror images across the dashed line \(y = x\). The point \((0, -4)\) on \(f\) becomes \((-4, 0)\) on \(f^{-1}\).

Step 4 of 5Practice

Type your answer and press Check. If you miss twice, open the worked solution. Then mark how it went.

\(f(x) = x^2 + 1\) and \(g(x) = x - 3\). Find \((f \circ g)(5)\).

Inside first: \(g(5) = 5 - 3 = 2\).

Then \(f(2) = 2^2 + 1 = 5\).

Same functions: \(f(x) = x^2 + 1\) and \(g(x) = x - 3\). Find \((g \circ f)(5)\).

Now \(f\) is inside: \(f(5) = 5^2 + 1 = 26\).

Then \(g(26) = 26 - 3 = 23\). A different answer from Problem 1: order matters.

\(f(x) = 3x - 2\) and \(g(x) = x^2 + 1\). Find \((f \circ g)(x)\) and simplify.

\(f(g(x))\): put \((x^2 + 1)\) in place of \(x\) in \(f\): \(3(x^2 + 1) - 2\).

Distribute: \(3x^2 + 3 - 2 = 3x^2 + 1\).

Same functions: \(f(x) = 3x - 2\) and \(g(x) = x^2 + 1\). Find \((g \circ f)(x)\). Expand and simplify.

\(g(f(x))\): put \((3x - 2)\) in place of \(x\) in \(g\): \((3x - 2)^2 + 1\).

\((3x - 2)^2 = 9x^2 - 12x + 4\).

Add 1: \(9x^2 - 12x + 5\).

Which function is one-to-one (so it has an inverse)?

  1. \(f(x) = x^2 + 1\)
  2. \(f(x) = x^3 + 1\)
  3. \(f(x) = |x| + 1\)
  4. \(f(x) = (x - 1)^2\)

Look for two different inputs with the same output.

(a) \(f(2) = f(-2) = 5\). Not one-to-one.

(c) \(f(2) = f(-2) = 3\). Not one-to-one.

(d) \(f(0) = f(2) = 1\). Not one-to-one.

(b) \(x^3\) always increases, so every output comes from just one input. This one.

Find the inverse of \(f(x) = 5x + 2\). Type only the right side of \(f^{-1}(x) = \) ...

Write \(y = 5x + 2\), then swap: \(x = 5y + 2\).

Subtract 2: \(x - 2 = 5y\). Divide by 5: \(y = \dfrac{x - 2}{5}\).

So \(f^{-1}(x) = \dfrac{x - 2}{5}\). Check: \(5 \cdot \dfrac{x - 2}{5} + 2 = x - 2 + 2 = x\).

Find the inverse of \(f(x) = x^3 + 2\). Type only the right side of \(f^{-1}(x) = \) ...

Write \(y = x^3 + 2\), then swap: \(x = y^3 + 2\).

Subtract 2: \(x - 2 = y^3\). Take the cube root of both sides: \(y = \sqrt[3]{x - 2}\).

So \(f^{-1}(x) = \sqrt[3]{x - 2}\). Check: \(\left(\sqrt[3]{x - 2}\right)^3 + 2 = x - 2 + 2 = x\).

Find the inverse of \(f(x) = \dfrac{2x}{x - 3}\). Type only the right side of \(f^{-1}(x) = \) ...

Write \(y = \dfrac{2x}{x - 3}\), then swap: \(x = \dfrac{2y}{y - 3}\).

Multiply both sides by \((y - 3)\): \(xy - 3x = 2y\).

Get the \(y\) terms on one side: \(xy - 2y = 3x\). Factor out \(y\): \(y(x - 2) = 3x\).

Divide by \((x - 2)\): \(f^{-1}(x) = \dfrac{3x}{x - 2}\).

Step 5 of 5Wrap-up

You can now chain functions from the inside out, and undo a one-to-one function by swapping \(x\) and \(y\) and solving for \(y\).

Read or watch next: OpenStax Intermediate Algebra 2e, 10.1 Finding Composite and Inverse Functions (free textbook, with more practice at the end of the section).

Also good: Khan Academy: Precalculus: Composite and inverse functions (unit) (short videos). Quick rules: Functions cheat sheet.

Something unclear? Ask your teacher bot a follow-up question, for example: "Why do we swap \(x\) and \(y\) to find an inverse?" It knows this course and can explain things another way.