Precalculus
Function Composition: How to Find and Use f(g(x))
By MathSolver Pro Editorial Team · Published
Composing functions means feeding the output of one function into another. It is how complicated formulas are built from simple pieces, and recognising those pieces is essential for inverses and for the chain rule in calculus.
What composition means
Given two functions and , the composition , read f composed with g or f of g, is the function that first applies and then applies to the result:
The order is the part that confuses people. The function written on the right, closest to , acts first. Think of an assembly line: enters machine , the product moves on to machine , and comes out. For this to work, every output of that you use must be an acceptable input of .
Composition is different from multiplication. The product means , which multiplies two outputs, while substitutes one function into the other. The small circle symbol is what tells them apart.
Composing two formulas
To find , take the formula for and replace every in it with the whole expression , in brackets. Then simplify.
Example 1: and
- .
- .
- At : , while .
The two orders give completely different functions. Composition is not commutative in general: and are usually different, and you should never assume they are equal. It is associative, though, so , and a chain of three functions can be computed from the inside out.
Example 2: composing a function with itself
- For , find .
- Substitute into : .
- Check at : and , and .
Always put brackets around the inner function when you substitute. Without them, for easily becomes , which is wrong.
Evaluating compositions from numbers and tables
Often you need only a single value. Work from the inside out: evaluate the inner function first, then use that result as the input of the outer function. It is not necessary to find the composed formula.
Suppose a table gives , , and , , . Then , , and . If the table had no value for at the number produced by , that composition would simply be undefined at that input.
Graphs work the same way. To find from two graphs, read off the graph of , then find that value on the x-axis of the graph of and read the output.
The domain of a composition
The domain of contains exactly the inputs that satisfy two conditions: is in the domain of , and is in the domain of . Simplifying the composed formula can hide the first condition, so find the domain from the original pieces.
Example 3: and
- . The input to the root must be at least zero, so the domain is .
- . Here only restricts the input, so the domain is .
Example 4: and
- First condition: needs .
- Second condition: needs its input not equal to 1, so , which means .
- Simplify: .
- The simplified formula only shows , but is also excluded because is undefined. Domain: all real numbers except 0 and 1.
A short example shows why this matters. If and , then , but only for . The formula alone suggests every real number works, which is false. The guide to domain and range covers the individual restrictions used here.
Decomposing a function
Decomposition runs the process backwards: given a complicated function , find simpler functions with . Look for an inner expression that is being acted on by an outer operation.
- : inner , outer .
- : inner , outer .
- : inner , outer .
- : inner , outer , or a three-step chain , , .
Decompositions are not unique, but the most useful one usually has a simple inner function. Writing the inner part as is exactly the habit you will need for the chain rule and for substitution in integration.
Composition in calculus and inverses
Two major topics depend on composition. First, the chain rule differentiates a composition: the derivative of is . For that gives . The derivative rules guide covers this in depth.
Second, two functions are inverses exactly when composing them in either order returns the input: and on the appropriate domains. For and , you get . This is the standard way to verify an inverse, as explained in inverse functions.
A real-world example: discounts and coupons
A shop offers 20 percent off and you also have a coupon for 10 dollars off. Let apply the discount to a price and apply the coupon. The order matters.
- Coupon first, then discount: .
- Discount first, then coupon: .
- For a 50 dollar item, the first order costs 32 dollars and the second costs 30 dollars.
Applying the percentage first always saves 2 dollars here, because the coupon is not reduced by the percentage. Situations like this, where one process feeds into another, are compositions, and they show why the order of and is not just a technicality.
Common mistakes
- Applying the functions in the wrong order: in , acts first.
- Multiplying by instead of substituting.
- Substituting without brackets, especially into powers and negative signs.
- Finding the domain from the simplified formula only and missing values excluded by the inner function.
- Assuming .
You can check both orders and their domains with the function composition calculator, which shows the substitution step explicitly.
Why composition is worth mastering
Almost every function you meet after algebra is built by composition. A formula for the temperature of a cooling drink, the position of a swinging pendulum or the value of an investment is typically a simple outer function, such as an exponential, a sine or a power, applied to a simpler inner expression. Being able to see that structure lets you predict the shape of a graph, find where a function is defined, and choose the right technique for derivatives and integrals.
Composition also explains graph transformations. Shifting the graph of three units to the right produces , which is composed with the inner function . Stretching it vertically by a factor of 2 produces , which is the outer function composed with . Seen this way, a transformation applied inside the brackets changes the input and acts horizontally, while one applied outside changes the output and acts vertically. That single observation explains why horizontal shifts seem to go the wrong way.
Practice problems with answers
Work these out on paper, then compare. Each uses one idea from the sections above.
- If and , find . Answer: .
- With the same functions, find . Answer: .
- If and , find the domain of . Answer: , so .
- Decompose . Answer: inner , outer .
- If , find . Answer: and .
If your answer to the first problem was , you applied the functions in the wrong order; that is the answer to the second problem. Mixing up the two orders is the most common error, and checking with a number such as catches it quickly: , while .
Frequently asked questions
Which function do I apply first in f(g(x))?
The inner one, . Evaluate first, then use that result as the input of . The function closest to always acts first.
Is f(g(x)) the same as f(x) times g(x)?
No. substitutes into , while multiplies the two outputs. For and , but .
When does f(g(x)) equal g(f(x))?
Only in special cases, such as when one function is the inverse of the other, when one is the identity function, or for particular pairs like two linear functions through the origin. In general the two orders differ.
How do I find the domain of a composite function?
Start with the domain of the inner function, then remove any inputs whose inner output is not allowed in the outer function. Do this before simplifying, because simplifying can hide restrictions.
Can I compose more than two functions?
Yes. Compositions chain naturally, so applies , then , then . Work from the innermost function outwards, and check at each stage that the output is allowed as the next input.