Math Core

Lesson 4.5 · Radicals and Inverse Functions

Function composition

Many real processes happen in stages: a price is discounted and then taxed, a balloon's radius grows with time and its volume grows with the radius. Composition chains functions together so the output of one becomes the input of the next. It's also the tool you'll use in the next lesson to test whether two functions undo each other.

Combining functions with arithmetic

Before chaining, recall that you can add, subtract, multiply and divide functions output by output. If f(x)=x2f(x) = x^2 and g(x)=x+3g(x) = x + 3, then

(f+g)(x)=x2+x+3,(fg)(x)=x2(x+3),(fg)(x)=x2x+3, x≠−3.(f + g)(x) = x^2 + x + 3, \qquad (fg)(x) = x^2(x + 3), \qquad \left(\frac{f}{g}\right)(x) = \frac{x^2}{x + 3}, \ x \ne -3.

Composition is different. Instead of combining two outputs, you feed one function into the other.

What composition means

Definition

Composition of functions

The composition of ff with gg is the function

(f∘g)(x)=f(g(x)).(f \circ g)(x) = f\big(g(x)\big).

Read f∘gf \circ g as "ff of gg." You apply gg first, then apply ff to the result.

Think of two machines in a row. The input xx goes into machine gg, which outputs g(x)g(x). That output goes straight into machine ff, which outputs f(g(x))f(g(x)). The function written on the right acts first, which is the reverse of reading order, so take care.

Worked example: Evaluating a composition

Let f(x)=2x+1f(x) = 2x + 1 and g(x)=x2g(x) = x^2. Find f(g(3))f(g(3)) and g(f(3))g(f(3)).

Work from the inside out.

  • f(g(3))f(g(3)): first g(3)=32=9g(3) = 3^2 = 9, then f(9)=2(9)+1=19f(9) = 2(9) + 1 = 19.
  • g(f(3))g(f(3)): first f(3)=2(3)+1=7f(3) = 2(3) + 1 = 7, then g(7)=72=49g(7) = 7^2 = 49.

The results are different: order matters in composition. In general, f∘gf \circ g and g∘fg \circ f are different functions.

Finding a formula for a composition

To find f(g(x))f(g(x)) as a formula, substitute the entire expression g(x)g(x) for every xx in ff. Parentheses help avoid mistakes.

Worked example: Composition formulas

Let f(x)=2x+1f(x) = 2x + 1 and g(x)=x2g(x) = x^2. Find f(g(x))f(g(x)), g(f(x))g(f(x)) and f(f(x))f(f(x)).

f(g(x))=f(x2)=2(x2)+1=2x2+1g(f(x))=g(2x+1)=(2x+1)2=4x2+4x+1f(f(x))=f(2x+1)=2(2x+1)+1=4x+3\begin{aligned} f(g(x)) &= f\left(x^2\right) = 2\left(x^2\right) + 1 = 2x^2 + 1 \\ g(f(x)) &= g(2x + 1) = (2x + 1)^2 = 4x^2 + 4x + 1 \\ f(f(x)) &= f(2x + 1) = 2(2x + 1) + 1 = 4x + 3 \end{aligned}

Check with the previous example: f(g(3))=2(9)+1=19f(g(3)) = 2(9) + 1 = 19 ✓ and g(f(3))=4(9)+12+1=49g(f(3)) = 4(9) + 12 + 1 = 49 ✓.

Common mistake

f(g(x))f(g(x)) is not the product f(x)⋅g(x)f(x) \cdot g(x). With f(x)=2x+1f(x) = 2x + 1 and g(x)=x2g(x) = x^2, the product is (2x+1)x2=2x3+x2(2x + 1)x^2 = 2x^3 + x^2, which is not 2x2+12x^2 + 1. The small circle in f∘gf \circ g means "plug in," never "multiply."

The domain of a composition

For xx to be allowed in f(g(x))f(g(x)), two things must be true:

  1. xx is in the domain of gg (so g(x)g(x) exists), and
  2. g(x)g(x) is in the domain of ff (so ff can accept it).

Domain of f ∘ g

The domain of f∘gf \circ g is every xx in the domain of gg for which g(x)g(x) is in the domain of ff. Find it from both functions, not just from the simplified formula.

Worked example: Finding the domain

  1. Let f(x)=xf(x) = \sqrt{x} and g(x)=x−5g(x) = x - 5. Find f(g(x))f(g(x)) and its domain.
  2. Let f(x)=x2f(x) = x^2 and g(x)=xg(x) = \sqrt{x}. Find f(g(x))f(g(x)) and its domain.

Solutions.

  1. f(g(x))=x−5f(g(x)) = \sqrt{x - 5}. The square root needs x−5≥0x - 5 \ge 0, so the domain is x≥5x \ge 5.
  2. f(g(x))=(x)2=xf(g(x)) = \left(\sqrt{x}\right)^2 = x. The formula xx alone looks like it accepts every real number, but g(x)=xg(x) = \sqrt{x} is only defined for x≥0x \ge 0. So the domain of f∘gf \circ g is x≥0x \ge 0.

The graph of part 1 is the graph of y=xy = \sqrt{x} shifted 55 units right. Composing with x−5x - 5 on the inside is exactly a horizontal shift, which connects composition to the transformations you studied earlier.

y = √x and y = √(x − 5): composing with g(x) = x − 5 shifts the graph 5 units right.Open in grapher →

Decomposing a function

Sometimes you go backward: you're given a complicated function and want to write it as a composition of simpler ones. Look for an "inside" expression that is being plugged into an "outside" operation.

For h(x)=(3x−1)4h(x) = (3x - 1)^4, the inside is 3x−13x - 1 and the outside is "raise to the 4th power." So h=f∘gh = f \circ g with g(x)=3x−1g(x) = 3x - 1 and f(x)=x4f(x) = x^4. For h(x)=x2+9h(x) = \sqrt{x^2 + 9}, you could use g(x)=x2+9g(x) = x^2 + 9 and f(x)=xf(x) = \sqrt{x}. Decompositions aren't unique, but the natural one is usually clear.

Composition in context

Worked example: Discount, then coupon

A jacket costs pp dollars. A store takes 20% off, c(p)=0.8pc(p) = 0.8p, and you also have a coupon for $10 off, d(p)=p−10d(p) = p - 10. For a $60 jacket, does the order matter?

  • Coupon first, then 20% off: c(d(60))=c(50)=0.8(50)=40c(d(60)) = c(50) = 0.8(50) = 40 dollars.
  • 20% off first, then coupon: d(c(60))=d(48)=48−10=38d(c(60)) = d(48) = 48 - 10 = 38 dollars.

Taking the percent off first is $2 cheaper. In formulas, c(d(p))=0.8p−8c(d(p)) = 0.8p - 8 while d(c(p))=0.8p−10d(c(p)) = 0.8p - 10: when the percent comes last, it also shrinks the coupon.

Tip

When evaluating from a table or graph, work from the inside out one step at a time: find g(a)g(a) first, write it down, then look up ff of that number.

Practice

Practice 1

Let f(x)=3x−4f(x) = 3x - 4 and g(x)=x2+1g(x) = x^2 + 1. Find f(g(2))f(g(2)).

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 2

Let f(x)=3x−4f(x) = 3x - 4 and g(x)=x2+1g(x) = x^2 + 1. Find g(f(2))g(f(2)).

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 3

Let f(x)=x2−1f(x) = x^2 - 1 and g(x)=x+3g(x) = x + 3. Find f(g(x))f(g(x)).

Enter an expression, e.g. 3x^2 - 2x + 1

Practice 4

Let f(x)=x2−1f(x) = x^2 - 1 and g(x)=x+3g(x) = x + 3. Find g(f(x))g(f(x)).

Enter an expression, e.g. 3x^2 - 2x + 1

Practice 5

Use the table to find f(g(1))f(g(1)).

xx11223344
f(x)f(x)33770055
g(x)g(x)22441133

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 6

Let f(x)=xf(x) = \sqrt{x} and g(x)=4−xg(x) = 4 - x. What is the domain of f(g(x))f(g(x))?

Enter an inequality, e.g. x >= 4, -2 < x <= 3, or x < 1 or x > 5

Practice 7

Let h(x)=x2+9h(x) = \sqrt{x^2 + 9}. Which pair of functions gives h(x)=f(g(x))h(x) = f(g(x))?

Practice 8

Let f(x)=2x−3f(x) = 2x - 3. Find f(f(f(1)))f(f(f(1))).

Enter a number. Fractions like 3/4 and sqrt(2) are OK.