On this page
Composite functions look scary because of the brackets inside brackets. The idea underneath is simple: two machines joined by a conveyor belt. Once you can see the belt, you can predict f(g(x)) before you calculate it.
What does f(g(x)) actually mean?
The open textbook OpenStax College Algebra 2e defines the composite function as (f∘g)(x) = f(g(x)): the output of one function becomes the input of another.
Read f(g(x)) as "f of g of x". The function written closest to x acts first. OpenStax Precalculus 2e gives the rule you already use for ordinary brackets: start with the innermost parentheses and work outwards.
So picture it like this:
x goes into machine g.
Whatever comes out of g drops straight into machine f.
What comes out of f is f(g(x)).
Swap the machines and you get g(f(x)): f works first, g works second. Same two machines, different line-up.
How do you chain two function machines? A worked example
Take two machines:
g(x) = x − 4, which subtracts 4.
f(x) = √x, which takes the square root and only accepts inputs that are 0 or more.
Before you work anything out, predict: which order can accept x = 1? Now run four sample inputs through both line-ups.
x = 16. f(g(16)) = √(16 − 4) = √12 ≈ 3.46. g(f(16)) = √16 − 4 = 4 − 4 = 0.
x = 9. f(g(9)) = √(9 − 4) = √5 ≈ 2.24. g(f(9)) = √9 − 4 = 3 − 4 = −1.
x = 4. f(g(4)) = √0 = 0. g(f(4)) = 2 − 4 = −2.
x = 1. f(g(1)) = √(1 − 4) = √(−3), which is not a real number, so the machine jams. g(f(1)) = 1 − 4 = −3, which is fine.
Two lessons fall out. The answers differ for every input, and one order rejects an input the other accepts.
Why does the order change the result?
OpenStax Precalculus 2e states it plainly: in general, f∘g and g∘f are different functions, and in many cases f(g(x)) ≠ g(f(x)).
The graph above shows why. The gold curve is f(g(x)) = √(x − 4): the square-root curve slid 4 units to the right, because the subtraction happens to x before the root. The blue curve is g(f(x)) = √x − 4: the same square-root curve dropped 4 units down, because the subtraction happens to the answer after the root.
A change made inside the bracket moves the graph sideways. A change made outside moves it up or down. At x = 9, the pink dashed line joins the two outputs, about 2.24 and −1, so you can see the gap directly.
Why does the order change the domain?
OpenStax College Algebra 2e gives the rule: the domain of f(g(x)) is the set of inputs x in the domain of g for which g(x) is in the domain of f.
Apply it to our pair:
f(g(x)) = √(x − 4). Any x can enter g, but g(x) = x − 4 must be 0 or more to enter f. So x ≥ 4. On the graph, the gold curve starts at x = 4, and the shaded strip from 0 to 4 is where it does not exist.
g(f(x)) = √x − 4. Now f acts first, so x itself must be 0 or more. After that, g accepts anything. So x ≥ 0, and the blue curve starts at x = 0.
A common trap is to simplify the final formula and read the domain from that alone. Always check the inner machine first, then check what it hands to the outer one.
How can you practise composite functions so they stick?
Try this five-step routine on every question for a week:
Name the inner and outer functions in words.
Predict, before calculating, whether f(g(x)) and g(f(x)) will match for x = 0, 1 and one larger number.
Run those inputs through both orders and compare with your prediction.
Write the domain using the two-gate check.
Sketch both graphs, or plot them on a graphing tool, and check that each curve starts where your domain says it should.
Parents can help without knowing the answer by asking one question: "Which machine goes first, and what does it do to the number?"
Seeing a graph shift as you swap the order helps. The Fermi Simulation Lab has interactive simulations for ideas that are easier to see than to read. If you get stuck on why a domain shrinks, Fermi's AI tutor notices where you are stuck and decides whether to explain, ask or show, drawing the figure as it goes.
Pick two functions from your textbook tonight, run four inputs through both orders, and see if the graph agrees with you.



