Intuition Why this page exists
The parent note showed you the machine-on-machine idea. But a real exam throws edge cases at you: what if the inner function outputs something the outer one can't eat? What if a function is its own undo? What if you compose the same machine twice? This page walks one worked example per case class — so no scenario surprises you.
Before anything else, one reminder we will lean on constantly:
Definition The two orders (read the circle right-to-left)
( f ∘ g ) ( x ) = f ( g ( x )) means do g first, then f .
The rightmost machine touches the input first. Picture an assembly line where the raw material enters on the right and the finished part exits on the left. The figure below draws exactly that line — and shows why the little circle ∘ in f ∘ g is read right-to-left .
Read the figure: the input x enters at the right, flows leftward through machine g (deep teal), whose output g ( x ) is handed off to machine f (burnt orange), which finally emits f ( g ( x )) at the left. The plum circle in the middle is the composition symbol ∘ — the arrow curving right-to-left is your reminder that the rightmost function runs first .
Every composition problem is one (or a blend) of these cells. Each example below is tagged with the cell it hits.
Cell
What makes it tricky
Example
A — Plain algebra, both orders
Show f ∘ g = g ∘ f
Ex 1
B — Domain trap (square root / log)
Inner output must fit outer's mouth
Ex 2
C — Zero & degenerate input
Denominator → 0 , undefined points
Ex 3
D — Self-composition f ∘ f
Same machine twice; watch fixed points
Ex 4
E — Inverse pair (composition = identity)
f ∘ g = x signals undo
Ex 5
F — Decompose a given h
Split into inner + outer
Ex 6
G — Real-world word problem (units!)
Chain two rate/conversion functions
Ex 7
H — Exam twist: solve f ( g ( x )) = k
Compose, then solve an equation
Ex 8
I — Sign/piecewise & limiting behaviour
Absolute value, quadrants, x → ∞
Ex 9
Prerequisites we quietly use: Domain and range of function , Inverse functions , and for one aside Exponential and logarithmic functions . If chain-rule calculus tempts you, that lives at Derivatives - chain rule — different topic, same nesting idea.
Worked example Example 1 (Cell A)
Given f ( x ) = 2 x − 1 and g ( x ) = x 2 .
Find ( f ∘ g ) ( x ) , ( g ∘ f ) ( x ) , and evaluate both at x = 3 .
Forecast: Guess now — will the two orders give the same polynomial? Same value at x = 3 ? Before reading on, trace the arrow-diagram below with your finger for x = 3 : send 3 through g -then-f , then through f -then-g , and jot the two exit numbers.
Worked example Example 1 — worked
Read the figure: the top track (teal g first, then orange f ) is f ∘ g ; the bottom track (orange f first, then teal g ) is g ∘ f . The input 3 splits down both tracks and exits at two different numbers — the visual proof that order matters.
Write ( f ∘ g ) ( x ) = f ( g ( x )) . Inner is g , so substitute g ( x ) = x 2 into f :
f ( x 2 ) = 2 ( x 2 ) − 1 = 2 x 2 − 1.
Why this step? The rightmost machine g runs first; its output x 2 becomes f 's input.
Write ( g ∘ f ) ( x ) = g ( f ( x )) . Now f runs first:
g ( 2 x − 1 ) = ( 2 x − 1 ) 2 = 4 x 2 − 4 x + 1.
Why this step? We replace every x in g 's rule (x 2 ) with the whole expression 2 x − 1 .
Evaluate at x = 3 .
( f ∘ g ) ( 3 ) = 2 ( 9 ) − 1 = 17 ; ( g ∘ f ) ( 3 ) = 4 ( 9 ) − 12 + 1 = 25 .
Why this step? Plugging a number confirms the two orders truly differ, not just look different — and matches the two exit numbers in the figure.
Verify: Trace by hand. ( f ∘ g ) ( 3 ) : g ( 3 ) = 9 , then f ( 9 ) = 17 ✓. ( g ∘ f ) ( 3 ) : f ( 3 ) = 5 , then g ( 5 ) = 25 ✓. Different values ⇒ order matters.
Recall Reveal the core rule
In f ( g ( x )) which machine runs first? ::: the inner one, g — the rightmost function always processes the input first.
Worked example Example 2 (Cell B)
Given f ( x ) = x and g ( x ) = 5 − x .
Find the formula and the domain of ( f ∘ g ) ( x ) .
Forecast: The naive answer is "x ≥ 0 because square root." Is that right here?
Build the composite: ( f ∘ g ) ( x ) = f ( 5 − x ) = 5 − x .
Why this step? We need the explicit formula before we can hunt for illegal inputs.
List the two gatekeepers. (a) x must be legal for g — always true, subtraction eats any real. (b) The output g ( x ) must be legal for f — square root needs ≥ 0 .
Why this step? A composite has two doors: the input door of g and the "handoff" door into f .
Impose the handoff condition: g ( x ) ≥ 0 ⇒ 5 − x ≥ 0 ⇒ x ≤ 5 .
Why this step? If g ever outputs a negative, ⋅ is undefined there.
( f ∘ g ) ( x ) = 5 − x , domain ( − ∞ , 5 ]
Verify: Test x = 5 : 0 = 0 ✓ (boundary allowed). Test x = 6 : − 1 undefined ✓ (excluded). The "x ≥ 0 " guess was wrong — the minus sign flips it.
Read the figure: the number line below shows the two gatekeeper conditions stacked. The teal band is where g accepts input (all x ); the orange band is where the handoff g ( x ) ≥ 0 holds (x ≤ 5 ). The composite lives only where both bands overlap — the shaded region ending at the plum boundary dot x = 5 .
Common mistake The transparent-inner trap
Students copy " ⇒ non-negative" straight onto x . But the square root guards g ( x ) , not x . Always solve g ( x ) ≥ 0 .
Worked example Example 3 (Cell C)
Given f ( x ) = x 1 and g ( x ) = x − 2 .
Find ( f ∘ g ) ( x ) and the value(s) of x where it blows up.
Forecast: A reciprocal explodes when its input is 0 . Which x makes g ( x ) = 0 ?
Compose: ( f ∘ g ) ( x ) = f ( x − 2 ) = x − 2 1 .
Why this step? Substituting g into f shows the denominator is x − 2 , not x .
Find the degenerate input: set denominator = 0 : x − 2 = 0 ⇒ x = 2 .
Why this step? Division by zero is undefined; that single point is a hole in the domain.
Describe limiting behaviour near x = 2 : as x → 2 + , x − 2 1 → + ∞ ; as x → 2 − , it → − ∞ .
Why this step? "Every scenario" means also the approach , not just the forbidden point.
( f ∘ g ) ( x ) = x − 2 1 , domain x = 2
Verify: x = 3 ⇒ 1/ ( 3 − 2 ) = 1 ✓. x = 1.5 ⇒ 1/ ( − 0.5 ) = − 2 ✓ (negative, matching left-approach). x = 2 undefined ✓.
Read the figure: the plot of x − 2 1 shows the vertical dashed plum asymptote at x = 2 . To its right (orange) the curve dives down from + ∞ ; to its left (teal) it climbs from − ∞ — exactly the two-sided blow-up described in step 3.
Worked example Example 4 (Cell D)
Given f ( x ) = 1 − x 1 .
Find ( f ∘ f ) ( x ) and ( f ∘ f ∘ f ) ( x ) .
Forecast: A weird one — does applying f three times bring you back to x ? Guess yes/no.
Compute ( f ∘ f ) ( x ) = f ( 1 − x 1 ) . Substitute 1 − x 1 into 1 − □ 1 . Take the denominator apart one move at a time:
1 − 1 − x 1 = 1 − x 1 − x − 1 − x 1 = 1 − x ( 1 − x ) − 1 = 1 − x − x .
Why this step? Before we can flip a fraction we must first write its denominator as a single fraction — that means a common denominator 1 − x .
Now take the reciprocal of that single fraction:
1 − x − x 1 = − x 1 − x = x x − 1 .
Why this step? Dividing 1 by a fraction flips it; the sign tidies up to x x − 1 .
Compute the third layer f ( ( f ∘ f ) ( x ) ) = f ( x x − 1 ) . Same two moves. First the denominator as one fraction:
1 − x x − 1 = x x − x x − 1 = x x − ( x − 1 ) = x 1 .
Then flip:
x 1 1 = x .
Why this step? Repeat the identical common-denominator-then-flip routine once more to test for a cycle.
( f ∘ f ) ( x ) = x x − 1 ( x = 1 , x = 0 ) , ( f ∘ f ∘ f ) ( x ) = x ( x = 1 , x = 0 )
(Why the restrictions? f itself dies at x = 1 ; the second layer feeds 1 − x 1 into f again, which dies when its input is 1 , i.e. x = 0 . So both x = 1 and x = 0 are barred throughout — stated here alongside the answer, not hidden below.)
Verify: Take x = 3 . f ( 3 ) = 1 − 3 1 = − 2 1 . f ( − 2 1 ) = 1 − ( − 2 1 ) 1 = 2 3 1 = 3 2 . f ( 3 2 ) = 1 − 3 2 1 = 3 1 1 = 3 ✓ — three applications return 3 .
Read the figure: the plum triangle of arrows shows the 3-cycle 3 → − 2 1 → 3 2 → 3 . Each arrow is one application of f ; after exactly three hops you land back on the start — the visual meaning of ( f ∘ f ∘ f ) ( x ) = x .
Worked example Example 5 (Cell E)
Given f ( x ) = 3 x + 6 and g ( x ) = 3 x − 6 .
Show f and g are inverses by composing both ways.
Forecast: If they undo each other, both ( f ∘ g ) ( x ) and ( g ∘ f ) ( x ) should collapse to x . Guess whether you'll get exactly x .
Do f ∘ g : f ( 3 x − 6 ) = 3 ⋅ 3 x − 6 + 6 = ( x − 6 ) + 6 = x .
Why this step? Composing outer-after-inner; the × 3 cancels the ÷ 3 , then + 6 cancels − 6 .
Do g ∘ f : g ( 3 x + 6 ) = 3 ( 3 x + 6 ) − 6 = 3 3 x = x .
Why this step? Both orders must give the identity I ( x ) = x for a genuine inverse pair — see Inverse functions .
( f ∘ g ) ( x ) = ( g ∘ f ) ( x ) = x ⇒ g = f − 1
Verify: x = 10 : g ( 10 ) = 3 4 , f ( 3 4 ) = 3 ⋅ 3 4 + 6 = 10 ✓. Composing with the identity leaves the input untouched — the tell-tale signature of inverses.
Read the figure: f (orange) and g (teal) are drawn as straight lines that are mirror images across the dotted plum y = x line . Reflecting one across y = x lands exactly on the other — the graphical fingerprint of an inverse pair, matching the algebraic collapse to x .
When does an inverse even exist? only when f is bijective — see Bijective functions .
Worked example Example 6 (Cell F)
Given h ( x ) = x 2 + 1 1 .
Find three functions so that h = f ∘ g ∘ k .
Forecast: Peel it like an onion from the inside out. What's the first thing a calculator computes?
Innermost k : the calculator first forms x 2 + 1 . Let k ( x ) = x 2 + 1 .
Why this step? Whatever sits deepest inside is applied first — it's the rightmost machine.
Middle g : next it takes a square root. Let g ( x ) = x .
Why this step? g eats k 's output x 2 + 1 and produces x 2 + 1 .
Outermost f : finally take the reciprocal. Let f ( x ) = x 1 .
Why this step? f eats x 2 + 1 and yields x 2 + 1 1 = h ( x ) .
k ( x ) = x 2 + 1 , g ( x ) = x , f ( x ) = x 1
Verify: At x = 0 : k = 1 , g = 1 , f = 1 ; and h ( 0 ) = 1 1 = 1 ✓. Decomposition isn't unique, but "innermost-out" is the reliable recipe.
Read the figure: the onion diagram shows three nested shells — the plum core x 2 + 1 (k ), the teal shell (g ), the orange skin x 1 (f ). Peeling from the outside inward is how you read h ; building from the core outward is how you compute it.
Worked example Example 7 (Cell G)
A factory: hours worked → gadgets → money.
Gadgets made from h hours: g ( h ) = 12 h (gadgets).
Revenue from n gadgets: r ( n ) = 8 n + 50 (rupees, the 50 is a fixed daily bonus).
Find revenue as a function of hours, then revenue for a 6 -hour shift.
Forecast: Which function is inner? (Hours come first in time!)
Identify the chain order. Hours enter first → g is inner; money comes out last → r is outer. So we want ( r ∘ g ) ( h ) .
Why this step? Real processes fix the order: you must make gadgets before you can sell them.
Compose: ( r ∘ g ) ( h ) = r ( 12 h ) = 8 ( 12 h ) + 50 = 96 h + 50 rupees.
Why this step? Feed g 's gadget-count output straight into r 's money rule; units flow hours→gadgets→rupees.
Evaluate at h = 6 : 96 ( 6 ) + 50 = 576 + 50 = 626 rupees.
Why this step? Answer the concrete question with the composite formula.
( r ∘ g ) ( h ) = 96 h + 50 , ( r ∘ g ) ( 6 ) = 626 rupees
Verify: Step by step: g ( 6 ) = 72 gadgets, r ( 72 ) = 8 ( 72 ) + 50 = 576 + 50 = 626 ✓. Units check: (rupees/gadget)(gadgets/hour)(hours)=rupees ✓.
Read the figure: the unit-tracking chain shows three labelled boxes — hours (teal) → gadgets (plum) → rupees (orange) — with the conversion factor written on each arrow. The point h = 6 is traced through: 6 h → 72 gadgets → 626 rupees, matching the verify line.
Worked example Example 8 (Cell H)
Given f ( x ) = x + 4 and g ( x ) = x 2 .
Solve ( f ∘ g ) ( x ) = 13 .
Forecast: You expect two solutions or one? (A square is lurking.)
Compose: ( f ∘ g ) ( x ) = f ( x 2 ) = x 2 + 4 .
Why this step? Turn the composition into a single equation we can solve.
Set equal and solve: x 2 + 4 = 13 ⇒ x 2 = 9 ⇒ x = ± 3 .
Why this step? Isolating x 2 and square-rooting produces both signs — never drop the ± .
x = 3 or x = − 3
Verify: x = 3 : g = 9 , f ( 9 ) = 13 ✓. x = − 3 : g = 9 , f ( 9 ) = 13 ✓. Both hit the target because g squishes ± 3 to the same 9 .
Read the figure: the parabola y = x 2 + 4 is cut by the horizontal plum line y = 13 . The two intersection points sit symmetrically at x = − 3 and x = + 3 — the picture-proof that a squared inner function hands you a ± pair.
The absolute value ∣ x ∣ is the classic sign-splitter: ∣ x ∣ = x when x ≥ 0 , and ∣ x ∣ = − x when x < 0 . We compose with it so every sign region appears.
Read the figure: the horizontal axis is the input x , the vertical axis is ( f ∘ g ) ( x ) = ∣ x − 2∣ . The deep-teal line is the left arm (x < 2 , rule 2 − x , slope − 1 ); the burnt-orange line is the right arm (x ≥ 2 , rule x − 2 , slope + 1 ); the plum dot marks the corner at x = 2 where both arms meet at height 0 . The two small arrows show both arms rising to + ∞ .
Worked example Example 9 (Cell I)
Given f ( x ) = ∣ x ∣ and g ( x ) = x − 2 .
Describe ( f ∘ g ) ( x ) = ∣ x − 2∣ over all sign regions, and its limit as x → ± ∞ .
Forecast: Where is the "corner"? What does the graph do far left and far right?
Compose: ( f ∘ g ) ( x ) = ∣ x − 2∣ .
Why this step? g shifts the input, f folds negatives up — the composite is a shifted V (the figure above).
Case split on the sign of g ( x ) = x − 2 :
x ≥ 2 (inner output ≥ 0 ): ∣ x − 2∣ = x − 2 , a line of slope + 1 — the orange right arm.
x < 2 (inner output < 0 ): ∣ x − 2∣ = − ( x − 2 ) = 2 − x , a line of slope − 1 — the teal left arm.
Why this step? Absolute value has two rules; we must show both sign regions.
Corner and limits: the two pieces meet at x = 2 where value = 0 (the plum vertex). As x → + ∞ , ∣ x − 2∣ → + ∞ ; as x → − ∞ , ∣ x − 2∣ → + ∞ .
Why this step? Degenerate/limiting behaviour completes the picture — the V opens upward forever on both sides.
( f ∘ g ) ( x ) = ∣ x − 2∣ = { x − 2 , 2 − x , x ≥ 2 x < 2
Verify: x = 5 ⇒ ∣3∣ = 3 and 5 − 2 = 3 ✓ (right piece). x = 0 ⇒ ∣ − 2∣ = 2 and 2 − 0 = 2 ✓ (left piece). x = 2 ⇒ ∣0∣ = 0 ✓ (vertex). All three land on the V drawn above.
Recall Self-test before you close the tab
Compute ( g ∘ f ) ( 3 ) for Ex 1's functions. ::: g ( f ( 3 )) = g ( 5 ) = 25 .
Domain of 5 − x ? ::: ( − ∞ , 5 ] .
What signals that f and g are inverses? ::: both compositions equal x (the identity).
Where does x − 2 1 blow up? ::: at x = 2 .
Innermost function of x 2 + 1 1 ? ::: k ( x ) = x 2 + 1 .
Mnemonic One line to remember
"Inner first, check the handoff, split every sign." — the three habits that clear every cell of the matrix.