AP · Precalculus · Composition and Inverse Functions
Composition of Functions
15 min readUpdated November 30, 2026FreeAP Precalculus, Exponential and Logarithmic Functions
A composite function feeds the output of one function into another: (f∘g)(x)=f(g(x)), where g acts first and f acts second. You evaluate it from the inside out, whether the functions are given as formulas, tables or graphs. Order matters, because f(g(x)) and g(f(x)) are usually different, and the identity function I(x)=x leaves any function unchanged.
Quick check
1If f(x)=x2−3, what is f(−2)?Show answerHide answer
f(−2)=(−2)2−3=4−3=1.
2If f(x)=2x+5, what is f(a+1)?Show answerHide answer
f(a+1)=2(a+1)+5=2a+7. The whole input a+1 replaces x.
3If g(3)=5 and f(5)=12, what is f(g(3))?Show answerHide answer
Evaluate f(g(a)) when f and g are given by formulas, tables or graphs.
Explain why f(g(x)) and g(f(x)) are usually different functions.
Write a composite function as a single formula.
Rewrite a given function as a composition of an inner and an outer function.
Describe what composing with the identity function does.
Key terms
Composite function
The function f∘g defined by (f∘g)(x)=f(g(x)): the output of g becomes the input of f.
In plain English
Do g, then do f to the result.
Don't write
"(f∘g)(x)=f(x)⋅g(x)"; the circle means composition, not multiplication.
Inner and outer function
In f(g(x)),g is the inner function, applied first, and f is the outer function, applied second.
In plain English
The inner function is the one in the middle of the brackets.
Don't write
"f is applied first because it is written first"; the function next to x goes first.
Identity function
The function I(x)=x, which returns every input unchanged. Its graph is the line y=x.
In plain English
The "do nothing" function.
Don't write
"I(x)=1"; that is a constant function, not the identity.
How do you evaluate f(g(a))?
Learn this:(f∘g)(x)=f(g(x)). Work from the inside out: find g(a) first, then use that number as the input to f.
From formulas: with f(x)=x2−3 and g(x)=2x+1,g(2)=5, so f(g(2))=f(5)=22.
From a table: find the inner value in one row, then look it up again in the other row.
x
0
1
2
3
4
f(x)
3
4
0
2
1
g(x)
2
0
4
1
3
For f(g(1)), the g row gives g(1)=0, and then the f row gives f(0)=3.
From a graph: read g(a) off the graph of g, then put it into f. The figure "The graph of y = g(x), made of a segment from (−2, 3) to (0, −1) and a segment from (0, −1) to (4, 3)" gives g(−1)=1, so with f(x)=x2−3,f(g(−1))=f(1)=−2.
Key idea
Inside first: the output of the inner function is the input of the outer function.
Check yourself
Using the table, find g(f(0)).
Show answerHide answer
1. The f row gives f(0)=3, and the g row gives g(3)=1.
Why does the order matter, and when does it not?
Take f(x)=x2 and g(x)=x+3. Then f(g(x))=(x+3)2, which adds 3 and then squares, while g(f(x))=x2+3, which squares and then adds 3. At x=1 these give 16 and 4. So composition is not commutative: in general f(g(x))=g(f(x)).
This links to transformations. With g(x)=x+3 inside, f(x+3) shifts the graph of f left 3 units. With g outside, f(x)+3 shifts it up 3 units. The same function g gives a horizontal change on the inside and a vertical change on the outside.
The identity function is the main exception. Because I(x)=x hands back its input,
f(I(x))=f(x)andI(f(x))=f(x)
so composing with I in either order leaves f unchanged, much as multiplying by 1 leaves a number unchanged. When f(g(x))=x and g(f(x))=x, each function undoes the other; that is the idea behind the note on Inverse Functions.
Check yourself
For f(x)=2x and g(x)=x−5, write f(g(x)) and g(f(x)).
Show answerHide answer
f(g(x))=2(x−5)=2x−10 and g(f(x))=2x−5. They differ, so the order matters.
How do you write a composite as one formula?
Replace every x in the outer function with the whole inner expression, in brackets, then simplify. For f(x)=x2−3x and g(x)=2x+1:
f(g(x))=(2x+1)2−3(2x+1)=4x2+4x+1−6x−3=4x2−2x−2
The brackets matter: the 3 multiplies all of 2x+1, not just 2x. Check by substituting a value: at x=2,g(2)=5 and f(5)=25−15=10, and 4(4)−2(2)−2=10 too.
Compositions often produce exponential functions in new forms. With f(x)=3x and g(x)=2x−1,f(g(x))=32x−1, which the exponent rules turn into 31⋅9x (see the note on Working with Exponential Expressions).
Examiner's eye
Marks are lost when brackets are left off the inner function. Write f(2x+1) with (2x+1) in every place x appeared.
Check yourself
For f(x)=x−4 and g(x)=x2, write g(f(x)) as one formula.
Show answerHide answer
g(f(x))=(x−4)2=x2−8x+16.
How do you split a function into inner and outer parts?
Ask what you would do to x first when you compute the function. That first step is the inner function g, and what is done to its result is the outer function f.
h(x)
Inner g(x)
Outer f(x)
(3x−5)4
3x−5
x4
2x2
x2
2x
x+7−1
x+7
x−1
x−25
x−2
x5
Always check by composing back: for the first row, f(g(x))=(3x−5)4, as required.
A decomposition is not unique. For example, (3x−5)4 is also f(g(x)) with g(x)=(3x−5)2 and f(x)=x2. Any split that composes back to h is correct, but splitting at the first operation is usually the most useful.
Check yourself
Write h(x)=(x2+1)3 as f(g(x)).
Show answerHide answer
g(x)=x2+1 and f(x)=x3. Then f(g(x))=(x2+1)3.
Which method fits the question?
The question gives you
Do this
A number, such as f(g(2))
Inside out: find g(2), then f of that
Tables or a graph
Read the inner value, then look it up for the outer function
"Write f(g(x))"
Substitute g(x), in brackets, for every x in f, then simplify
A single h(x) to split
The first operation on x is the inner function
Worked example 1: Composing from a table
Question: Use the table of f and g in the section on evaluating, where f(0),f(1),f(2),f(3),f(4) are 3,4,0,2,1 and g(0),g(1),g(2),g(3),g(4) are 2,0,4,1,3. Find (a) f(g(2)), (b) g(f(2)), (c) f(g(f(4))).
What tells you the method
Every value is a lookup, so work from the innermost function outward.
1
Step 1: Part (a).
g(2)=4, then f(4)=1.
Why
g is inside, so it is read first.
2
Step 2: Part (b).
f(2)=0, then g(0)=2.
Why
Now f is inside; the order has swapped.
3
Step 3: Part (c).
f(4)=1, then g(1)=0, then f(0)=3.
Why
With three layers, keep working outward one lookup at a time.
Check it
Parts (a) and (b) give 1 and 2, different results for the same input, as the order rule predicts.
Answer
(a) f(g(2))=1. (b) g(f(2))=2. (c) f(g(f(4)))=3.
Worked example 2: Both orders as formulas
Question: Let f(x)=x2+1 and g(x)=3x−2. Write f(g(x)) and g(f(x)) as single formulas, and evaluate both at x=1.
What tells you the method
"write as single formulas" means substitute and expand.
1
Step 1: Find f(g(x)).
f(3x−2)=(3x−2)2+1=9x2−12x+4+1=9x2−12x+5.
Why
g(x), in brackets, replaces x in f.
2
Step 2: Find g(f(x)).
g(x2+1)=3(x2+1)−2=3x2+1.
Why
Now f(x) replaces x in g.
3
Step 3: Evaluate at x=1.
f(g(1))=9−12+5=2 and g(f(1))=3+1=4.
Why
This confirms the two orders give different functions.
Check it
Inside out, g(1)=1 and f(1)=2; also f(1)=2 and g(2)=4. Both match.
Answer
f(g(x))=9x2−12x+5 and g(f(x))=3x2+1; at x=1 they equal 2 and 4.
Worked example 3: An exponential composite
Question: Let h(x)=5⋅23x+1. (a) Write h(x)=f(g(x)), where g is linear and f is exponential. (b) Rewrite h(x) in the form a⋅bx.
What tells you the method
The exponent 3x+1 is computed first, so it is the inner function.
1
Step 1: Split the function.
g(x)=3x+1 and f(x)=5⋅2x.
Why
Then f(g(x))=5⋅23x+1=h(x).
2
Step 2: Split the exponent.
23x+1=2⋅23x=2⋅8x.
Why
The product rule, then (23)x=8x.
3
Step 3: Combine constants.
h(x)=5⋅2⋅8x=10⋅8x.
Why
The form a⋅bx has one constant in front.
Check it
At x=0,5⋅21=10 and 10⋅80=10.
Answer
(a) g(x)=3x+1 and f(x)=5⋅2x. (b) h(x)=10⋅8x, so a=10 and b=8.
Your turn
Question: Let f(x)=x and g(x)=x2+9. Find f(g(4)), and write g(f(x)) as a single formula for x≥0.
1
Step 1:
Inside first: g(4)=16+9=25.
2
Step 2: Your go: apply f to 25, then substitute x into g.
Show the full solutionHide the solution
f(25)=25=5. For the formula, g(x)=(x)2+9=x+9, which holds for x≥0, where x is defined.
Answer:f(g(4))=5, and g(f(x))=x+9 for x≥0.
Traps
Trap
Thinking f(g(2)) starts by finding f(2).
It seems right because f is written first and you read left to right. But the input 2 goes into g first, so you find g(2) and then apply f to it.
Check yourself
With f(x)=x+1 and g(x)=3x, which is f(g(2)):7 or 9?
Show answerHide answer
7.g(2)=6 and f(6)=7. The value 9 is g(f(2)).
Trap
Thinking (f∘g)(x) means f(x)⋅g(x).
It seems right because the small circle looks like a multiplication dot. But ∘ means composition: (f∘g)(x)=f(g(x)).
Check yourself
For f(x)=x+2 and g(x)=4x, find (f∘g)(1).
Show answerHide answer
6, because g(1)=4 and f(4)=6. Multiplying would give 3×4=12.
Trap
Thinking f(2x+1) for f(x)=x2−3x is 2x+12−3⋅2x+1.
It seems right because you only swap x for the new expression. But the whole expression replaces x, so it needs brackets: (2x+1)2−3(2x+1).
Check yourself
For f(x)=5−x, write f(x+4).
Show answerHide answer
5−(x+4)=1−x. Without brackets you would get 5−x+4=9−x, which is wrong.
What's examined
Composition of functions is part of Unit 2 (Exponential and Logarithmic Functions) of the AP® Precalculus exam, in both the multiple-choice and free-response sections. Expect to evaluate composites from formulas, tables and graphs, write a composite as one formula, and split a function into inner and outer parts. All of it is done by hand. The same skill sets up inverse functions, which have their own note.
Practice questions
Recall Let f(x)=2x+1 and g(x)=x2. What is (f∘g)(3)?
A) 49
B) 19
C) 63
D) 16
Show answer
Answer: B) 19
Marking points:
g(3)=9, then f(9)=19.
A is g(f(3))=72. C multiplies f(3)⋅g(3)=7×9. D adds f(3)+g(3).
Recall The table gives values of f and g:f(1)=3,f(2)=4,f(3)=1,f(4)=2, and g(1)=2,g(2)=4,g(3)=1,g(4)=3. Find f(g(3)) and g(f(3)).
x
1
2
3
4
f(x)
3
4
1
2
g(x)
2
4
1
3
Show answer
Answer:f(g(3))=3 and g(f(3))=2.
Marking points:
g(3)=1, then f(1)=3.
f(3)=1, then g(1)=2.
Apply Let f(x)=x−4 and g(x)=x2. Which expression is g(f(x))?
A) x2−4
B) x2−16
C) x3−4x2
D) x2−8x+16
Show answer
Answer: D) x2−8x+16
Marking points:
g(f(x))=(x−4)2=x2−8x+16.
A is f(g(x)). B squares each term separately. C multiplies f(x)⋅g(x).
Apply The graph of g is made of two line segments, from (−2,3) to (0,−1) and from (0,−1) to (4,3), as in the figure "The graph of y = g(x), made of a segment from (−2, 3) to (0, −1) and a segment from (0, −1) to (4, 3)". Let f(x)=2x−1. Find f(g(0)) and g(f(2)).
Show answer
Answer:f(g(0))=−3 and g(f(2))=2.
Marking points:
g(0)=−1, so f(−1)=2(−1)−1=−3.
f(2)=3; on the segment from (0,−1) to (4,3),g(x)=x−1, so g(3)=2.
Apply Let h(x)=5x+2. Which pair of functions gives h(x)=f(g(x))?
A) f(x)=x and g(x)=5x+2
B) f(x)=5x+2 and g(x)=x
C) f(x)=x and g(x)=5x
D) f(x)=5x and g(x)=x+2
Show answer
Answer: A) f(x)=x and g(x)=5x+2
Marking points:
5x+2 is computed first, so it is the inner function, and the square root is the outer one.
B gives 5x+2, the reverse order. C gives 5x, missing the 2. D gives 5x+10.
Exam-style Let f(x)=4⋅3x and g(x)=2x−1. (a) Write f(g(x)) in the form a⋅bx. (b) Find g(f(1)).
Show answer
Answer: (a) f(g(x))=34⋅9x, so a=34 and b=9. (b) g(f(1))=23.
Marking points:
f(g(x))=4⋅32x−1=4⋅3−1⋅(32)x=34⋅9x.
f(1)=12, so g(12)=24−1=23.
Exam-style Let f(x)=x2−2x and g(x)=x+k, where k is a constant. If f(g(x))=x2+4x+3 for all x, what is the value of k?
A) −1
B) 2
C) 3
D) 4
Show answer
Answer: C) 3
Marking points:
f(x+k)=(x+k)2−2(x+k)=x2+(2k−2)x+k2−2k.
Matching x terms: 2k−2=4, so k=3; the constant 9−6=3 also matches.
A solves only k2−2k=3 and fails the x term. B ignores the −2x in f. D reads the coefficient 4 as k.
Key points
Recall, then reveal
Say the main points from memory first, then check them.
Show key pointsHide key points
f(g(x)) means apply g first, then f; evaluate from the inside out with formulas, tables or graphs.
Swapping the order usually changes the result, so f∘g and g∘f are different functions.
To write a composite as one formula, put the inner expression in brackets wherever x appears in the outer function.
To split h(x), the first operation on x is the inner function; check by composing back.
The identity I(x)=x changes nothing: f(I(x))=I(f(x))=f(x).
Figures
(open full size in a new tab)The graph of y = g(x), made of a segment from (−2, 3) to (0, −1) and a segment from (0, −1) to (4, 3)