FiveWay Premium

Unlock every question

1,292 more practice questions, 134 Killer problems, timed mock exams in the 2027 format, and sets built from the skills you miss.

Current accessGuestYou are browsing without an account. Sign in to keep your record.

Free

Always, no account needed to read

  • A 7-question diagnostic and the first 8 practice questions in every topic
  • A worked solution and a note on each wrong choice for those questions
  • Every concept note, in every chapter
  • Your record and My page

Premium

Everything in Free, plus

  • The other 1,292 questions — every chapter, to the end
  • 134 Killer problems, pitched above the exam ceiling
  • Timed mock exams in the 2027 format — 42 questions, 105 minutes
  • Sets built from the skills you keep missing, refilled weekly
  • Analytics — accuracy per skill, time per question, your weak chapters
Unlock early access

Early access is free while we test. No card, no timer. Compare plans

Sign in to FiveWay

Sign in to keep your answers and see which skills to fix.

  • Free to start
  • No password
  • Progress saved on every device

We store your answers and the skills they belong to. Your first name and last initial appear only on the leaderboard and in Community.

Topic 2.7B

Composition of Functions

In 2.7A we evaluated compositions one number at a time: first the inside value, then the outside function. That works, but if you need f(g(x))f(g(x)) for many inputs, it is better to build one formula that does both steps at once. This note builds those formulas, finds where they are defined, and runs the process in reverse by breaking a complicated function into simpler pieces.

9 MIN READ6 IDEAS33 PROBLEMS10 flashcards

01

Building a Formula for f(g(x))

CONCEPT

Substitute the Whole Inside Function

To find f(g(x))f(g(x)), take the formula for ff and replace every xx with the entire expression g(x)g(x), in parentheses.

Then simplify. The result is a single function that does gg and then ff.

Worked example

With f(x)=x2−3f(x) = x^{2} - 3 and g(x)=2x+1g(x) = 2x + 1 from 2.7A, find formulas for f(g(x))f(g(x)) and g(f(x))g(f(x)).

  1. 01

    f(g(x))f(g(x)): replace xx in ff with (2x+1)(2x + 1):

    f(g(x))=(2x+1)2−3=4x2+4x−2f\big(g(x)\big) = (2x + 1)^{2} - 3 = 4x^{2} + 4x - 2
  2. 02

    g(f(x))g(f(x)): replace xx in gg with (x2x^{2} − 3):

    g(f(x))=2 (x2−3)+1=2x2−5g\big(f(x)\big) = 2\,(x^{2} - 3) + 1 = 2x^{2} - 5
  3. 03

    Check against 2.7A: 4(2)2+4(2)−2=22=f(g(2))4(2)^{2} + 4(2) - 2 = 22 = f(g(2)) ✓, and 2(2)2−5=3=g(f(2))2(2)^{2} - 5 = 3 = g(f(2)) ✓. Two different formulas, as expected, because order matters.

    Remember from 2.4: Nova's weekly model was exactly this. With T(w)=w/4T(w) = w/4 and N(t)=256(1.5)tN(t) = 256(1.5)^{t}, N(T(w))=256(1.5)w/4N(T(w)) = 256(1.5)^{w/4}.

COMMON MISTAKE

“f(g(x))=x2−3f(g(x)) = x^{2} - 3 with 2x+12x + 1 stuck on: 2x+12−32x + 1^{2} - 3.”

The whole inside function must go in parentheses before squaring: (2x+1)2(2x + 1)^{2}, not 2x+122x + 1^{2}. Without parentheses only the 1 gets squared. Check with x=2x = 2: the wrong version gives 2, but f(g(2))f(g(2)) is 22.

02

The Domain of a Composition

CONCEPT

Two Conditions

xx is in the domain of f(g(x))f(g(x)) exactly when (1)x(1) x is in the domain of gg, AND (2) the value g(x)g(x) is in the domain of ff.

Remember from 2.7A: g(f(5))g(f(5)) was undefined because f(5)=−1f(5) = -1 was outside g's domain. The same thing happens with formulas.

Worked example

Example 1. f(x)=xf(x) = \sqrt{x} and g(x)=5−xg(x) = 5 - x. Find the domains of f(g(x))f(g(x)) and g(f(x))g(f(x)).

  1. 01

    f(g(x))f(g(x)) = √(5−x5 - x). The square root needs 5−x≥05 - x \ge 0, so x≤5x \le 5. (For example, x=5x = 5 gives 0 and x=1x = 1 gives 2, but x=6x = 6 gives −1\sqrt{-1}, not real.)

  2. 02

    g(f(x))=5−xg(f(x)) = 5 - \sqrt{x}. Here the inside function x\sqrt{x} needs x≥0x \ge 0 first. After that, 5 − (anything) is fine. Domain: x≥0x \ge 0.

  3. 03

    Same two functions, opposite orders, different domains: x≤5x \le 5 versus x≥0x \ge 0.

Worked example

Example 2. f(x)=1/(x−3)f(x) = 1/(x - 3) and g(x)=x2−1g(x) = x^{2} - 1. Find f(g(x))f(g(x)) and its domain.

  1. 01

    Substitute:

    f(g(x))=1(x2−1)−3=1x2−4,x≠2,  x≠−2f\big(g(x)\big) = \frac{1}{(x^{2} - 1) - 3} = \frac{1}{x^{2} - 4}, \qquad x \ne 2,\; x \ne -2
  2. 02

    ff can't take the input 3, so exclude every xx with g(x)=3g(x) = 3: x2−1=3x^{2} - 1 = 3 gives x2=4x^{2} = 4, so x=2x = 2 or x=−2x = -2. Remember from 2.1 and 2.5A: an even power has two roots, and here BOTH must be excluded.

  3. 03

    Domain: all real xx except 2 and −2. Check a value that works: f(g(3))=1/(9−4)=1/5f(g(3)) = 1/(9 - 4) = 1/5.

    A hidden restriction. Let f(x)=x2f(x) = x^{2} and g(x)=xg(x) = \sqrt{x}. Then f(g(x))=(x)2f(g(x)) = (\sqrt{x})^{2}, which simplifies to xx. But the simplified formula hides a restriction: gg only accepts x≥0x \ge 0, so f(g(x))f(g(x)) is defined only for x≥0x \ge 0.

    Figure

    The formulas look the same after simplifying, but the composition keeps the domain of the inside function.

COMMON MISTAKE

“(x)2=x(\sqrt{x})^{2} = x, so the domain of f(g(x))f(g(x)) is all real numbers.”

Find the domain BEFORE simplifying. The inside function x\sqrt{x} already throws out every negative input, and simplifying afterward can't bring them back. (Compare √(x2x^{2}): at x=−3x = -3 it gives 3, not −3, so it is not xx either.)

Quick check

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

03

Decomposing a Function

Sometimes you need to go backwards: given one function, find an inside function gg and an outside function ff so that h(x)=f(g(x))h(x) = f(g(x)). Ask yourself: what is calculated FIRST, and what is done to it?

h(x)inside g(x)outside f(x)
(3x−1)4(3x - 1)^{4}3x − 1x4x^{4}
2x22^{x^{2}}x2x^{2}2x2^{x}
√(x2x^{2} + 9)x2x^{2} + 9√x
256(1.5)w/4256(1.5)^{w/4}w/4256(1.5)w256(1.5)^{w}

There is usually more than one correct decomposition. For (3x−1)4(3x - 1)^{4} you could also use g(x)=(3x−1)2g(x) = (3x - 1)^{2} and f(x)=x2f(x) = x^{2}. What doesn't help is the trivial split f(x)=xf(x) = x, g(x)=h(x)g(x) = h(x): it is correct, but it says nothing.

Worked example

Example 3. Decompose h(x)=2x+5h(x) = \sqrt{2x + 5} and k(x)=5x2−1k(x) = 5^{x^{2} - 1}.

  1. 01

    Ask: if I plug in a number, what do I calculate FIRST? For hh at x=2x = 2: first 2(2)+5=92(2) + 5 = 9, then 9=3\sqrt{9} = 3. So the inside is g(x)=2x+5g(x) = 2x + 5 and the outside is f(x)=xf(x) = \sqrt{x}.

  2. 02

    For kk at x=2x = 2: first 22−1=32^{2} - 1 = 3, then 53=1255^{3} = 125. Inside g(x)=x2−1g(x) = x^{2} - 1, outside f(x)=5xf(x) = 5^{x}.

  3. 03

    Check by composing back: f(g(x))f(g(x)) = √(2x+52x + 5) ✓ and 5x2−15^{x^{2} - 1} ✓.

Quick check

Write h(x)=(x2−9)4h(x) = (x^2 - 9)^4 as f(g(x))f(g(x)) with gg the inner function.

04

Transformations Are Compositions

CONCEPT

Composing With a Linear Function

A change to the OUTPUT happens after ff, so it is a linear function on the outside: 2f(x)−3=L(f(x))2f(x) - 3 = L(f(x)) with L(x)=2x−3L(x) = 2x - 3.

A change to the INPUT happens before ff, so it is a linear function on the inside: f(x+2)=f(S(x))f(x + 2) = f(S(x)) with S(x)=x+2S(x) = x + 2, and f(3x)=f(M(x))f(3x) = f(M(x)) with M(x)=3xM(x) = 3x.

The identity function I(x)=xI(x) = x changes nothing: f(I(x))=I(f(x))=f(x)f(I(x)) = I(f(x)) = f(x).

Remember from 2.4: “If Nova had launched 2 months earlier” was N(t+2)=N(S(t))N(t + 2) = N(S(t)), an input change, and it equaled 576(1.5)t576(1.5)^{t}, which is an output change (a vertical stretch). The same function can be seen as either composition.

In 2.8 you will meet pairs of functions that undo each other, so that f(g(x))=xf(g(x)) = x: composition with the result being the identity.

Worked example

Example 4. Let f(x)=x2f(x) = x^{2}. Write g(x)=3f(x−2)+1g(x) = 3f(x - 2) + 1 as a composition, and find its formula.

  1. 01

    Inside (acts first on x): S(x)=x−2S(x) = x - 2, a shift right by 2.

  2. 02

    Outside (acts on the output of f): L(x)=3x+1L(x) = 3x + 1, a vertical stretch by 3 and a shift up 1. So g(x)=L(f(S(x)))g(x) = L(f(S(x))): three functions in a row.

  3. 03

    Formula: g(x)=3(x−2)2+1=3x2−12x+13g(x) = 3(x - 2)^{2} + 1 = 3 x^{2} - 12x + 13. Check: g(2)=1g(2) = 1 (the vertex moved to (2,1)(2, 1)) and g(3)=3(1)+1=4g(3) = 3(1) + 1 = 4.

Worked example

Try it yourself. (a) f(x)=x+4f(x) = x + 4, g(x)=x2g(x) = x^{2}. Find f(g(x))f(g(x)) and g(f(x))g(f(x)), and check both at x=1x = 1. (b) f(x)=xf(x) = \sqrt{x}, g(x)=x−7g(x) = x - 7. Find f(g(x))f(g(x)) and its domain. (c) Decompose h(x)=(x+5)3h(x) = (x + 5)^{3}.

Answers: (a) f(g(x))=x2+4f(g(x)) = x^{2} + 4 and g(f(x))=(x+4)2=x2+8x+16g(f(x)) = (x + 4)^{2} = x^{2} + 8x + 16. At x=1x = 1: 5 and 25. (b) x−7\sqrt{x - 7}, domain x≥7x \ge 7. (c) g(x)=x+5g(x) = x + 5, f(x)=x3f(x) = x^{3}.

05

Practice

Worked example

P1. f(x)=3xf(x) = 3x and g(x)=x−4g(x) = x - 4. Find f(g(x))f(g(x)) and g(f(x))g(f(x)).

Answer: f(g(x))=3(x−4)=3x−12f(g(x)) = 3(x - 4) = 3x - 12. g(f(x))=3x−4g(f(x)) = 3x - 4.

Worked example

P2. f(x)=1/xf(x) = 1/x and g(x)=x−6g(x) = x - 6. Find f(g(x))f(g(x)) and its domain.

Answer: f(g(x))=1/(x−6)f(g(x)) = 1/(x - 6). ff can't take 0, so exclude xx with x−6=0x - 6 = 0: all real xx except 6.

Worked example

P3. Decompose h(x)=e2x+1h(x) = e^{2x + 1} into f(g(x))f(g(x)).

Answer: g(x)=2x+1g(x) = 2x + 1 (inside) and f(x)=exf(x) = e^{x} (outside).

Worked example

P4. f(x)=xf(x) = \sqrt{x} and g(x)=x2−4g(x) = x^{2} - 4. Find f(g(x))f(g(x)) and its domain.

Answer: f(g(x))f(g(x)) = √(x2x^{2} − 4). Need x2−4≥0x^{2} - 4 \ge 0. The boundary x2=4x^{2} = 4 has two roots, x=±2x = \pm 2, so the domain is x≤−2x \le -2 or x≥2x \ge 2. (x=1x = 1 fails: −3\sqrt{-3} is not real; x=3x = 3 and x=−3x = -3 both give 5\sqrt{5}.)

Common slips

  • “f(g(x))=x2−3f(g(x)) = x^{2} - 3 with 2x+12x + 1 stuck on: 2x+12−32x + 1^{2} - 3.”

    The whole inside function must go in parentheses before squaring: (2x+1)2(2x + 1)^{2}, not 2x+122x + 1^{2}. Without parentheses only the 1 gets squared. Check with x=2x = 2: the wrong version gives 2, but f(g(2))f(g(2)) is 22.

  • “(x)2=x(\sqrt{x})^{2} = x, so the domain of f(g(x))f(g(x)) is all real numbers.”

    Find the domain before simplifying. The inside function x\sqrt{x} already throws out every negative input, and simplifying afterward can't bring them back. (Compare √(x2x^{2}): at x=−3x = -3 it gives 3, not −3, so it is not xx either.)

Lock it in

Try the flashcards

10 cards · Composition and inverses

Start

Recap card

6 lines to re-read the night before.

  1. 01

    To build f(g(x))f(g(x)), substitute the whole expression g(x)g(x), in parentheses, for xx in ff. Then simplify.

  2. 02

    Domain of f(g(x))f(g(x)): xx must be in the domain of gg And g(x)g(x) must be in the domain of ff. Find it before simplifying.

  3. 03

    When excluding values, solve g(x)g(x) = (bad input) completely; an even power gives two values to exclude.

  4. 04

    Decomposing: the inside function is what is computed first. Several decompositions can be correct.

  5. 05

    Output changes are compositions on the outside, input changes on the inside. I(x)=xI(x) = x changes nothing.

  6. 06

    Next, in 2.8: inverse functions, functions that undo each other, so that f(g(x))=xf(g(x)) = x.

Premium feature

Unlock Premium

Every question, sets from your misses, mock exams and more.

Current accessFree

  • Every practice question
  • Sets from your misses
  • Mock exams

Free during early access — no card. Your progress stays exactly where it is. Compare plans