Skip to main content
Mathovia

Algebra / Graphing and Functions

Function Composition: Feeding One Function Into Another

Composition chains two functions together: the output of one becomes the input of the next. It is written f(g(x)) or (f ∘ g)(x), and the thing that trips everyone up is the order — the function written on the inside runs first. This lesson covers evaluating at a number, building the composed formula, why f∘g and g∘f are usually different, how to find the domain, and how to decompose a complicated function back into simpler pieces.

Practice Problems
M
Written by
Mathovia Team
Editorial Team

Composition is what happens when two rules run back to back. Convert pounds to euros, then apply a booking fee. Take a measurement, then square it. The output of the first becomes the input of the second, and that chain is a function in its own right.

Function composition f of g of x, also written f composed with g
The composition of f with g

The Idea

The ring symbol is read “composed with”, but says the same thing and is usually clearer.

The critical point is order: the inner function runs first.

Two machines in series: the input 3 goes into a box labelled add 1 producing 4, which feeds a box labelled square it producing 16
Two machines in series — the inner one goes first.

Written , the sits on the left but acts second. That is exactly the same convention as arithmetic brackets: in you do the bracket first. Reading left to right is the instinct to fight here.

Evaluating at a Number

Work from the inside out, one step at a time.

Step-by-step: g(3) = 4, then f(4) = 16, giving f(g(3)) = 16
Evaluate the inner function, then feed the answer outward.

With and , find :

  1. Inner first: .
  2. Outer second: .

So .

Doing it in two written steps is worth the extra line. Trying to do both at once is where sign and bracket errors creep in.

Building the Composed Formula

To get a general expression, substitute the whole of into wherever appears.

The brackets are essential. squares its entire input, so it is , not .

A useful habit: write first, then drop into the box. It makes the substitution mechanical.

Order Matters

Composition is not commutative. Swapping the order almost always gives a different function.

Comparison showing f(g(x)) = x squared plus 2x plus 1 while g(f(x)) = x squared plus 1
f∘g and g∘f are usually different functions.

With the same and :

Check at : the first gives 9, the second gives 5. Genuinely different.

There is one important case where the order does not matter: when is the inverse of . Then both compositions return the input unchanged, which is precisely what “inverse” means.

The Domain of a Composition

Two conditions must hold at once, and the second is the one people miss.

  1. must be in the domain of the inner function .
  2. must be in the domain of the outer function .
A chain of two machines, the first requiring x at least 0 and the second requiring its input not equal to 2
The input has to survive both boxes, not just the first.

Worked case. and , for :

  • needs .
  • needs its input , so , which rules out .

Domain: .

Looking only at the composed formula would catch the exclusion, but a formula that simplifies can hide the inner restriction entirely — which is why checking separately is the safer routine. See Domain.

Decomposing a Function

The reverse skill: given a complicated function, find two simpler ones that compose to make it. This is essential for the chain rule in calculus.

Look for an expression being acted on as a whole. That inner expression is ; whatever is done to it is .

FunctionInner Outer

Decompositions are not unique — could also be with . The useful one is normally the most obvious inner bracket.

Composition vs Multiplication

These two get confused constantly, so it is worth being explicit.

NotationMeaningExample with ,
‘s output feeds
outputs multiplied

At : composition gives 9, multiplication gives 12. See Combining Functions for the arithmetic operations.

Worked Example A: Numbers Both Ways

, . Find and .

  • : , then .
  • : , then .

Different, as expected.

Worked Example B: The Composed Formula

, . Find and .

Worked Example C: A Negative Inside a Square

, . Find .

, then .

The bracket around matters — without it the square would come out negative.

Worked Example D: Domain of a Composition

, . Find and its domain.

accepts everything, but needs a non-negative input, so . Domain: .

Worked Example E: Decomposition

Write as a composition.

The bracket is cubed as a whole, so and . Check: . ✓

Worked Example F: A Real Chain

A shop takes 20% off, then adds 5% tax on the reduced price.

A £50 item costs £42. Reversing the order, — here the two happen to agree, because both are simple multiplications. That is the exception, not the rule.

Common Mistakes to Avoid

  • Running the outer function first. In , goes first.
  • Assuming . They differ in almost every case.
  • Confusing composition with multiplication. .
  • Dropping brackets on substitution. with is .
  • Checking only the composed formula for the domain. The inner function’s restriction still applies.
  • Reading as multiplication. The ring is composition, not a product.
  • Forgetting brackets around a negative intermediate value.

Where Composition Leads Next

  • Inverse functions, defined by — the one case where order does not matter.
  • The chain rule in calculus, which differentiates a composition and depends on decomposing correctly.
  • Transformations, since is a composition with a shift.
  • Unit conversion chains, where each step is a function applied to the last result.
  • Programming, where piping the output of one function into another is the same idea.

Practice Problems

Use and for Problems 1–4.

Problem 1. Find .

Show answer

, then .

Problem 2. Find .

Show answer

, then .

Problem 3. Find .

Show answer

.

Problem 4. Find .

Show answer

.

Problem 5. For and , find .

Show answer

, then .

Problem 6. For the same functions, find .

Show answer

.

Problem 7. For and , find the domain of .

Show answer

needs , so .

Problem 8. Decompose .

Show answer

and .

Problem 9. Decompose .

Show answer

and .

Problem 10. For and , find and .

Show answer

Both give . These functions are inverses of each other.

Problem 11. A price rises 10%, then a £5 voucher is deducted. Write the final price as a composition of and .

Show answer

.

Problem 12. Using the same functions, is the same?

Show answer

. Different — the voucher is worth more when deducted after the rise.

Quick Reference

ItemMeaning
OrderInner function runs first
EvaluatingInside out, one step at a time
Building the formulaSubstitute all of into , with brackets
Commutative?No — in general
Domain in domain of , and in domain of
vs multiplication chains; multiplies
DecomposingFind the expression acted on as a whole
The inverse case, where order does not matter

Composition is one of two ways to build a function from two others — the arithmetic route is Combining Functions. It underpins inverse functions and relies on function notation and domain. More Algebra lessons are available.

Frequently Asked Questions

What is function composition?+

Composition applies one function to the result of another. means: work out first, then use that answer as the input to . It is also written .

Which function goes first in f(g(x))?+

The inner one. In , runs first and runs second, even though is written on the left. It is the same reading order as brackets in arithmetic — innermost first.

Is f(g(x)) the same as g(f(x))?+

Almost never. Composition is not commutative. With and , but — different functions.

What is the difference between f(g(x)) and f(x)g(x)?+

is composition: the output of becomes the input of . is a product: both functions are evaluated at the same input and the two answers are multiplied.

How do you find the domain of a composition?+

The input must be in the domain of the inner function, and the value the inner function produces must be in the domain of the outer one. Both conditions have to hold, so check the inner function's restrictions as well as the composed formula's.

How do you decompose a function?+

Look for an inner expression that is being acted on as a whole. In , the inner function is and the outer is , because the root is applied to the whole bracket.

Related lessons