f(g(x)) means run g first, then feed its output into f. The order almost always changes the result. The domain shrinks: x must be allowed into g, and g(x) must be allowed into f.
Step 1: Let's Learn
Read it, or press Listen and follow the words.
Try it first
A jacket costs $60. The shop is running two offers: "take $10 off" and "take 20% off". Ravi uses the $10 off first and then the 20% off. Maya uses the 20% off first and then the $10 off. What does each of them pay?
Stuck is fine. Let’s Learn shows the way next. Got it first time? You can jump ahead to Watch an Example.
A composed formula
f(g(x)) = x² + 3: put x² wherever f has x. g(f(x)) = (x + 3)² = x² + 6x + 9: put x + 3 wherever g has x. Two different functions.
Check with the numbers
x² + 3 at x = 2 is 7. (x + 3)² at x = 2 is 25. The formulas agree with the values computed one step at a time.
The domain shrinks
g(x) = √x and f(x) = 1/(x − 2). f(g(x)) = 1/(√x − 2) needs x ≥ 0 for the root and √x ≠ 2, so x ≠ 4. Both conditions apply.
Running it backwards
h(x) = √(3x + 1) is f(g(x)) with g(x) = 3x + 1 and f(x) = √x. Seeing the layers is what the chain rule in calculus will need.
The special case
When f(g(x)) = x and g(f(x)) = x, the two are inverses of each other. f(x) = 2x + 1 and g(x) = (x − 1)/2: f(g(x)) = 2 · (x − 1)/2 + 1 = x.
In context
A price is discounted 20%, then taxed 10%: t(d(p)) = 1.1 × 0.8p = 0.88p. Taxed first, then discounted: 0.8 × 1.1p = 0.88p. Here the order happens not to matter, because both are multipliers.
Step 2: Try It Yourself
Tap and try it out.
f(x) = 1/(x − 2) and g(x) = √x. Find f(g(x)), its domain, and g(f(9))
- 1f(g(x)) = 1/(√x − 2)√x goes wherever f has x
Step 3: In Real Life
Currency then tax
A travel app converts dollars to euros, then adds a booking fee. The output of the first function is the input of the second. Every chained calculation in software is a composition.
Step 4: Watch an Example
One step at a time.
Watch Yusuf Compose Two Rules Both Ways
A fresh pair of rules: f(x) = 3x − 2 and g(x) = x² + 1. Yusuf writes each composite as a single formula, expands it, and checks both at x = 2.
- Step 1
Yusuf starts with f(g(x)), which runs g first. Whatever number arrives, g squares it and adds 1; f then triples what it receives and takes 2 away. So the whole of g(x) is what f receives, and it goes wherever f has an x: f(g(x)) = 3(x² + 1) − 2.
Watch Priya Start It, Then Finish It Yourself
f(x) = x² − 2x and g(x) = x + 5. Priya sets up f(g(x)) and expands the square; the rest is yours.
- Step 1
Priya takes f(g(x)) first, so g runs first and hands over x + 5. That whole bracket goes wherever f has an x, and f has two of them: f(g(x)) = (x + 5)² − 2(x + 5). Missing the second x is the commonest slip here, so she writes both before touching either.
Watch Dev Rule a Number Out
f(x) = 1/(x − 3) and g(x) = x − 4. Both composites exist, and each one refuses a different number.
- Step 1
Dev looks at the two rules on their own first. f has exactly one number it cannot take: at x = 3 the bottom of the fraction is 0. g takes anything at all, because subtracting 4 is safe for every number.
Step 5: Your Turn
Practice makes it stick.
The Coupon and the Sale
Problem 1 of 2
A store has a 25% off sale, and you also hold a coupon worth $15 off. The jacket you want is priced at $80. The till applies the sale first and the coupon second. What do you pay, in dollars?
Hours to Take-Home
Problem 2 of 2
A tutor is paid $22 for each hour worked, and 15% of that pay is deducted before it reaches her account. Writing p(h) for the pay on h hours and t(x) for what is left of x dollars, what is t(p(20)), in dollars?
Run Them In Order
The rule written closest to the input goes first. Then its output is what the outer rule receives.
1 of 5
f(x) = 4x − 1 and g(x) = x + 6. What is f(g(2))?
2 of 5
The same two rules: f(x) = 4x − 1 and g(x) = x + 6. What is g(f(2))?
3 of 5
f(x) = x − 5 and g(x) = 3x. Write f(g(x)) as a single rule in x, with no brackets left.
4 of 5
f(x) = x² and g(x) = x − 4. Write f(g(x)) as a single rule in x, with no brackets left.
5 of 5
f(x) = 2x + 3 and g(x) = (x − 3)/2. Write f(g(x)) as a single rule in x, with no brackets left.
Whose Step?
One line on each page is a slip. Find it, then put it right.
1 of 4
Noor worked out f(g(4)) with f(x) = x² and g(x) = x − 1. One line is a slip. Which?
Noor’s working for f(g(4))
- 1f(x) = x², g(x) = x − 1
- 2f(g(4)): the 4 goes into f first, so f(4) = 16
- 3g(16) = 15
- Answerf(g(4)) = 15
2 of 4
What is f(g(4)), correctly?
3 of 4
Leo wrote f(g(x)) as one rule, with f(x) = 2x + 1 and g(x) = x − 4. One line is a slip. Which?
Leo’s working for f(g(x))
- 1f(x) = 2x + 1, g(x) = x − 4
- 2f(g(x)) = 2(x − 4) + 1
- 3f(g(x)) = 2x − 4 + 1
- Answerf(g(x)) = 2x − 3
4 of 4
Write f(g(x)) correctly, as a single rule in x with no brackets left.
Pick the Move
Decide which way round the rules go. Neither question needs the composite written out in full.
1 of 2
h(x) = (5x + 2)³. Which pair of rules composes to h, in the order f(g(x))?
2 of 2
A ticket site lists a seat at $40. It takes 10% off for members, and it adds a $5 booking fee. Both happen, but the site chooses the order. Which order do you want, and what does it cost?
Same Function?
Judge these by reasoning about the rules, not by grinding every one out in full.
1 of 2
Select every pair for which f(g(x)) and g(f(x)) are the same function.
2 of 2
f(x) = x² and g(x) = x + 1. Select every expression that is equal to f(g(x)).
Step 6: Quick Check
Show what you know.
Question 1 of 1
f(x) = x + 2, g(x) = 5x. f(g(3))?
Ready for more?Optional. Past the lesson, for anyone who wants it.
Stretch 1 of 2
f(x) = ax + 1 and g(x) = x + 4, where a is a number. For which value of a is f(g(x)) the same function as g(f(x))?
Stretch 2 of 2
g(x) = x − 3. There is a rule f for which f(g(x)) = x² for every x. Type f’s rule, written in x.
What You Learned
- f(g(x)) runs g first, then f.
- The order almost always changes the result.
- The domain of a composite needs both functions to accept their inputs.
- When both composites return x, the functions are inverses.
For the grown-up
The misconception this lesson targets is reading f(g(x)) left to right, as though f went first because it is written first. The notation runs inside out, and the bracket is what says so. Its cousin is the quiet assumption that the order cannot matter — the jacket in the opener is $2 cheaper one way round than the other, and that $2 is the whole idea. A third, subtler one is that a composite inherits its domain from the outer function alone: 1/(x − 3) refuses 3, but with a subtraction wrapped inside it the number it refuses becomes 7 instead. Any doubt on any of the three is settled the same way, by running one number through both rules one step at a time and comparing it with the single formula.