Worked examples
The question
Question: find f(g(x)) and g(f(x)) for f(x) = x + 2 and g(x) = 3x.
f(x) = x + 2
g(x) = 3x
1 Find f(g(x))
f(g(x)) is a function inside a function.
Like with brackets, we start inside.
First g(x).
inside first: g(x)
g(x) is 3x.
So f(g(x)) is f(3x).
f(g(x)) = f(3x)
Put (3x) in place of every x in f.
We keep it in brackets.
= (3x) + 2
A bracket with a plus or nothing in front can just be removed.
( ) away
Now we have 3x + 2.
f(g(x)) = 3x + 2
2 Find g(f(x))
g(f(x)) is a function inside a function.
Like with brackets, we start inside.
First f(x).
f(x) is x + 2.
So g(f(x)) is g(x + 2).
g(f(x)) = g(x + 2)
Put (x + 2) in place of every x in g.
We keep it in brackets.
= 3(x + 2)
The 3 in front of the bracket multiplies every part inside.
a(b + c) = ab + ac
So we write 3 times each part.
= 3(x) + 3(2)
3 times x is 3x.
3 times 2 is 6.
g(f(x)) = 3x + 6
3 Compare
3x + 2 and 3x + 6 are not the same.
So the order matters!
3x + 2 ≠ 3x + 6
Careful!
Inside first, then outside.
Swap them, and you usually get a different rule.
Careful: f(g(x)) is usually not g(f(x))
4 Check
Let's check with a number: x = 1.
g of 1 is 3, then f of 3 is 5.
f(g(1)) = f(3) = 5
f of 1 is 3, then g of 3 is 9.
Different, as we found.
g(f(1)) = g(3) = 9
And our rules give the same numbers: 3x + 2 gives 5, 3x + 6 gives 9.
They are right!
3x + 2 → 5, 3x + 6 → 9
Let's look back.
First: find f(g(x)).
Then: find g(f(x)).
Then: compare.
Last: check.
▶ Watch it solved
The question
Question: find f(g(x)) and g(f(x)) for f(x) = 2x + 1 and g(x) = x + 3.
f(x) = 2x + 1
g(x) = x + 3
1 Find f(g(x))
f(g(x)) is a function inside a function.
Like with brackets, we start inside.
First g(x).
inside first: g(x)
g(x) is x + 3.
So f(g(x)) is f(x + 3).
f(g(x)) = f(x + 3)
Put (x + 3) in place of every x in f.
We keep it in brackets.
= 2(x + 3) + 1
The 2 in front of the bracket multiplies every part inside.
a(b + c) = ab + ac
So we write 2 times each part.
= 2(x) + 2(3) + 1
2 times x is 2x.
2 times 3 is 6.
= 2x + 6 + 1
Terms are the parts between the + and − signs.
Like terms are the same kind: same letters, same powers.
Plain numbers go together.
Each colour is one kind.
like terms = same letters,
same powers
6 + 1 is 7.
6 + 1 = 7
So the expression is 2x + 7.
f(g(x)) = 2x + 7
2 Find g(f(x))
g(f(x)) is a function inside a function.
Like with brackets, we start inside.
First f(x).
f(x) is 2x + 1.
So g(f(x)) is g(2x + 1).
g(f(x)) = g(2x + 1)
Put (2x + 1) in place of every x in g.
We keep it in brackets.
= (2x + 1) + 3
A bracket with a plus or nothing in front can just be removed.
( ) away
Now we have 2x + 1 + 3.
= 2x + 1 + 3
Terms are the parts between the + and − signs.
Like terms are the same kind: same letters, same powers.
Plain numbers go together.
Each colour is one kind.
like terms = same letters,
same powers
1 + 3 is 4.
1 + 3 = 4
So the expression is 2x + 4.
g(f(x)) = 2x + 4
3 Compare
2x + 7 and 2x + 4 are not the same.
So the order matters!
2x + 7 ≠ 2x + 4
Careful!
Inside first, then outside.
Swap them, and you usually get a different rule.
Careful: f(g(x)) is usually not g(f(x))
4 Check
Let's check with a number: x = 1.
g of 1 is 4, then f of 4 is 9.
f(g(1)) = f(4) = 9
f of 1 is 3, then g of 3 is 6.
Different, as we found.
g(f(1)) = g(3) = 6
And our rules give the same numbers: 2x + 7 gives 9, 2x + 4 gives 6.
They are right!
2x + 7 → 9, 2x + 4 → 6
Let's look back.
First: find f(g(x)).
Then: find g(f(x)).
Then: compare.
Last: check.
▶ Watch it solved
The question
Question: find f(g(x)) and g(f(x)) for f(x) = x² and g(x) = x + 1.
f(x) = x2
g(x) = x + 1
1 Find f(g(x))
f(g(x)) is a function inside a function.
Like with brackets, we start inside.
First g(x).
inside first: g(x)
g(x) is x + 1.
So f(g(x)) is f(x + 1).
f(g(x)) = f(x + 1)
Put (x + 1) in place of every x in f.
We keep it in brackets.
= (x + 1)2
A square means the bracket times itself.
(x + 1)² is x + 1 times x + 1.
( )² = ( )( )
Careful!
We can't just square each part.
x² + 1 is wrong.
The middle part is missing.
Careful: not (x + 1)2 = x² + 1 ✗
So we write the bracket two times.
= (x + 1)(x + 1)
Each part of the first bracket multiplies the whole second bracket.
(a + b)(c + d) = a(c + d) + b(c + d)
The parts of the first bracket are x and 1.
Each one takes the whole second bracket.
= x(x + 1) + 1(x + 1)
What is in front of a bracket multiplies every part inside.
a(b + c) = ab + ac
So we write each part times what is in front.
= x(x) + x(1) + 1(x) + 1(1)
x times x is x².
x times 1 is x.
1 times x is x.
1 times 1 is 1.
= x2 + x + x + 1
Terms are the parts between the + and − signs.
Like terms are the same kind: same letters, same powers.
All the x terms go together.
Each colour is one kind.
like terms = same letters,
same powers
x + x is 2x.
It is like 1 apple plus 1 apple: that is 2 apples.
x + x = 2x
So the expression is x² + 2x + 1.
f(g(x)) = x2 + 2x + 1
2 Find g(f(x))
g(f(x)) is a function inside a function.
Like with brackets, we start inside.
First f(x).
f(x) is x².
So g(f(x)) is g(x²).
g(f(x)) = g(x2)
Put (x²) in place of every x in g.
We keep it in brackets.
= (x2) + 1
A bracket with a plus or nothing in front can just be removed.
( ) away
Now we have x² + 1.
g(f(x)) = x2 + 1
3 Compare
x² + 2x + 1 and x² + 1 are not the same.
So the order matters!
x² + 2x + 1 ≠ x² + 1
4 Check
Let's check with a number: x = 1.
g of 1 is 2, then f of 2 is 4.
f(g(1)) = f(2) = 4
f of 1 is 1, then g of 1 is 2.
Different, as we found.
g(f(1)) = g(1) = 2
And our rules give the same numbers: x² + 2x + 1 gives 4, x² + 1 gives 2.
They are right!
x² + 2x + 1 → 4, x² + 1 → 2
Let's look back.
First: find f(g(x)).
Then: find g(f(x)).
Then: compare.
Last: check.
Answer x² + 2x + 1 ≠ x² + 1
▶ Watch it solved