On this concept: Formula

Not sure which lesson to do first? Find your level and get a plan →

Math · Advanced Functions · Grade 9-12

Function Composition

Composition (f∘g)(x)=f(g(x)) runs g first, then feeds its output into f.

(f∘g)(x)=f(g(x))

Quick Answer

Composition (f∘g)(x)=f(g(x)) runs g first, then feeds its output into f. Use it when a process happens in stages and each stage starts from the previous result: convert dollars to euros and then subtract a fee, or find a ripple's radius after t seconds and then the area it encloses. Composing turns the two-step calculation into a single formula. Order usually matters: squaring then adding 1 is not the same as adding 1 then squaring.

Why This Matters

Real formulas are usually built in layers, and composition is how you build and take apart those layers. It turns 'temperature depends on altitude, and altitude depends on time' into one rule for temperature over time. It is also what defines an inverse, f(f−1(x))=x, and it is the structure behind the chain rule in calculus.

Intuitive Explanation

A shop takes 20% off and then adds 8% sales tax to the sale price. The discount is g(p)=0.8p and the tax is f(s)=1.08s. A $50 jacket becomes g(50)=40, then f(40)=43.20. Composing writes both stages as one rule: f(g(p))=1.08(0.8p)=0.864p, and 0.864×50=43.20, matching the two-step answer.

The notation reads right to left. In (f∘g)(x) the function next to x, which is g, acts first, just as the inner brackets of f(g(x)) are worked out first. To get a formula, substitute the whole expression g(x) wherever x appears in f. With f(x)=x2 and g(x)=x+1, f(g(x))=(x+1)2.

Composition is not multiplication. The product f(x)⋅g(x)=x2(x+1) uses the same input in both functions side by side; composition sends the input through one function and then the other. The order also changes the result: g(f(x))=x2+1 while f(g(x))=(x+1)2, and at x=3 these give 10 and 16. The shop example is an exception only because multiplying by 0.8 and by 1.08 can be done in either order.

Think of it like this. Composition is a relay race: the second runner cannot start until the first hands over the baton, and what the second runner carries is exactly what the first delivered. Swap the running order and the finish can change, just as (x+1)2 differs from x2+1.

Core idea. Composition feeds the result of the inner function straight into the outer function.


When to Use

Compose when one quantity depends on a second that itself depends on a third, so the output of one rule becomes the input of the next: area depends on radius and radius depends on time; a fee depends on the euro amount and the euro amount depends on dollars. Words like 'then' or a written f(g(x)) are the signal. If two functions act on the same input side by side and are added or multiplied, as in revenue = price × quantity, use function arithmetic instead.

Tip. Ask: Is the output of one function being used as the input of another, in a fixed order?

How to Recognize It

Before composing, trace what each stage takes in and what it hands on, so you know which rule acts first and what the final answer measures.

  1. Do the units chain, so the first rule produces exactly the kind of quantity the second rule needs?

    Yes, as with time giving a radius and radius giving an area, means compose: A(r(t)). If both rules take the same input, such as price and quantity sold both depending on the week, combine them with arithmetic instead.

  2. Is the stage that acts on the raw input the one written inside?

    It must be: in (f∘g)(x), g acts first. If the story runs the other way, write g∘f, which usually gives a different result, as (x+1)2 differs from x2+1.

  3. Is the task to multiply the two outputs?

    Yes means a product: with f(x)=x+1 and g(x)=2x, f(x)⋅g(x)=2x2+2x, while f(g(x))=2x+1. If one output is substituted into the other formula, it is composition.

  4. Does the second stage exactly undo the first, returning the original input?

    Yes means the two are inverse functions, a special pairing whose composition always gives x. No means an ordinary composition, which carries the process forward to a new quantity.

Function Composition compared with Multiplication of functions, Reversed composition, and Inverse function

Each row combines two functions, so the notation looks alike. Ask how the second function gets its input: from the first one's output (composition), in the opposite order (reversed), from the same x side by side (multiplication), or so as to cancel the first (inverse).

Function Composition

Meaning
Use this when a process happens in stages and the output of one function becomes the input of another.
Key test
Is the output of one function being used as the input of another, in a fixed order?
Formula
(f∘g)(x)=f(g(x))
Example
Given f(x)=x+1 and g(x)=x2, find (f∘g)(3).

Multiplication of functions

Meaning
Multiplies the two outputs together; does not feed one into the other.
Key test
Use when the problem says product, not 'plug into.'
Formula
f(x)⋅g(x)
Example
(x+1)(x2) multiplies; f(g(x)) substitutes

Reversed composition

Meaning
Applies the functions in the opposite order, giving a different result.
Key test
Use when the problem genuinely runs the other function first.
Formula
g(f(x))
Example
(f∘g)(x)≠(g∘f)(x) in general

Inverse function

Meaning
The special partner that composes with f to return the input unchanged.
Key test
Use when the second function is meant to undo the first, not extend it.
Formula
f−1(f(x))=x
Example
Composing a function with its inverse gives x

Formula & Notation

(f∘g)(x)=f(g(x))
(f∘g) ⁣:X→Z defined by (f∘g)(x)=f(g(x))  ∀x∈X, where g ⁣:X→Y and f ⁣:Y→Z

How to read it: (f∘g)(x) denotes f composed with g: apply g first, then f to the result.

Worked Examples

Example 1 — Compose two functions

Easy

Given f(x)=x+1 and g(x)=x2, find (f∘g)(3).
Show the steps and the answer
  1. Read (f∘g)(3) as f(g(3)) and start with the inner function g.

    f cannot act until g(3) is known, so the innermost brackets come first.

  2. Compute g(3)=32=9.

    g squares its input.

  3. Feed 9 into f: f(9)=9+1=10.

    The output of g becomes the input of f.

Answer: (f∘g)(3)=10

Takeaway: Work from the inside out: the function written next to the input acts first.

Example 2 — Wrong order

Standard

With f(x)=x+1 and g(x)=x2, a student computes (g∘f)(3) and expects 10. Same answer?
Show the steps and the answer
  1. Read (g∘f)(3) as g(f(3)): now f is inside, so it acts first.

    Swapping the letters swaps which rule the input meets first.

  2. Compute f(3)=4, then g(4)=42=16.

    Adding 1 before squaring gives (3+1)2, while squaring first gives 32+1.

  3. Compare the formulas: (g∘f)(x)=(x+1)2=x2+2x+1, but (f∘g)(x)=x2+1.

    They differ by 2x, so they agree only at x=0; composition is generally not commutative.

Answer: (g∘f)(3)=16, not 10

Takeaway: f(g(x)) and g(f(x)) usually differ, so always check which function sits inside.

Example 3 — Find the mistake: substitute, do not multiply

Application

With f(x)=3x−1 and g(x)=x+4, Noah finds (f∘g)(x) and writes: "(f∘g)(x)=(3x−1)(x+4)=3x2+11x−4." Find the mistake and correct it.
Show the steps and the answer
  1. Test Noah's formula at x=1: 3+11−4=10.

    Comparing one value against the definition is a quick way to catch a wrong formula.

  2. Compute f(g(1)) from the definition: g(1)=5, then f(5)=3(5)−1=14.

    14 is not 10, so the formula is wrong: Noah multiplied f(x) by g(x) instead of feeding g into f.

  3. Substitute g(x) for the x in f: f(x+4)=3(x+4)−1=3x+12−1=3x+11.

    Composition replaces the input of f with the entire output of g.

  4. Check at x=1: 3(1)+11=14.

    The corrected formula agrees with the step-by-step value.

Answer: (f∘g)(x)=3x+11

Takeaway: The small circle in f∘g means substitute, not multiply; the product is written f(x)⋅g(x).

Where You'll See It

  • Ripples spreading on a pond

    A ripple's radius grows as r(t)=2t metres, and the area inside it is A(r)=πr2. Composing gives A(r(t))=π(2t)2=4πt2, so after 3 seconds the disturbed area is 36π≈113 m², found in one step.

  • Changing money, then paying a fee

    A bureau converts dollars to euros with E(d)=0.9d, then charges a €5 fee, N(e)=e−5. Changing $200 gives N(E(200))=180−5=175 euros. Taking a $5 fee before converting gives E(195)=175.5 euros instead, so the order matters.

  • A weather balloon cooling as it rises

    Air cools about 6.5∘C per km of height: T(h)=15−6.5h. If a balloon climbs as h(t)=0.2t km after t minutes, then T(h(t))=15−1.3t, so 10 minutes after launch the air around it is about 2∘C.

Common Mistakes

  1. The slip: Applying f before g in (f∘g)(x)

    Instead: the inner function g always goes first.

  2. The slip: Multiplying outputs instead of substituting

    Instead: composition plugs g(x) in for the variable in f, it does not multiply.

  3. The slip: Assuming f∘g equals g∘f

    Instead: order changes the result for most functions.


Mini Practice

Try these on your own. Tap Reveal when you want to check.

  1. Let f(x)=2x−1 and g(x)=x+4. Find (f∘g)(2).

    Hint: Work from the inside out: which function gets the 2 first?

  2. Let f(x)=x2 and g(x)=3x−2. Find (f∘g)(x) and (g∘f)(x).

    Hint: Substitute the whole inner expression for x in the outer function.

  3. A table gives g(1)=4, g(4)=2, f(2)=5 and f(4)=0. Find f(g(1)) and g(g(1)).

    Hint: Find g(1) first, then use that number as the next input.

  4. A shop takes $5 off, d(p)=p−5, and then adds 10% tax, t(p)=1.1p. Find t(d(40)) and say what it means.

    Hint: Apply the discount to $40 first, then the tax.

  5. With f(x)=x+2 and g(x)=x−2, a problem asks for the area of a rectangle whose sides are f(x) and g(x). Composition or multiplication of functions?

    Hint: Is one output being fed into the other function, or are two outputs combined?

  6. For f(x)=x2 and g(x)=x+3, a student computes '(f∘g)(1)=f(1)⋅g(1)=1⋅4=4.' Find and correct the mistake.

    Hint: Composition substitutes; it does not multiply. Which function acts first?

Want the full set?

50 practice questions for this concept — free to try, every one with a complete worked solution showing the why, not just the answer.

Frequently Asked Questions

Can I compose any two functions?

Only where the inner output is a legal input for the outer function. With g(x)=x−5g(x)=x-5 and f(x)=xf(x)=\sqrt{x}, f(g(x))=x−5f(g(x))=\sqrt{x-5} needs x≥5x\ge 5, even though gg accepts every real number. So the domain of f∘gf\circ g is the set of inputs to gg whose outputs land in the domain of ff. Checking that handover is the step people most often skip.

Do f∘g and g∘f ever give the same function?

Sometimes. If f(x)=x+2f(x)=x+2 and g(x)=x+5g(x)=x+5, both orders give x+7x+7, because additions can be done in either order. A function and its inverse also give the same result in both orders, namely xx. These are exceptions, though: f(x)=2xf(x)=2x and g(x)=x+1g(x)=x+1 give 2x+22x+2 one way and 2x+12x+1 the other, so always check the order.

How do I split a complicated function into a composition?

Look for an inside chunk that is computed first. In h(x)=(3x−1)5h(x)=(3x-1)^5, the inner function is g(x)=3x−1g(x)=3x-1 and the outer is f(u)=u5f(u)=u^5, so h=f∘gh=f\circ g. Splitting this way is not just a puzzle: in calculus, the chain rule differentiates a composition by handling the outer and inner layers separately, so spotting the layers now saves effort later.

How do I find f(g(2)) from two tables instead of formulas?

Read from the inside out. Find 2 in the gg table and note its output, say g(2)=7g(2)=7. Then find 7 in the input column of the ff table and read its output, say f(7)=−1f(7)=-1. So f(g(2))=−1f(g(2))=-1. If 7 is not listed as an input of ff, then f(g(2))f(g(2)) cannot be found from the data, which exam questions sometimes test on purpose.

Learning Path

← Before

Function
Function Composition

You are here

You need Function, including evaluating a rule at an expression such as f(x+4). Composition adds chaining, where one rule's output feeds the next and the order matters. Next, Inverse Function uses composition to define undoing: f−1 is the function with f(f−1(x))=x and f−1(f(x))=x.

See Also