Step by step
The question
Question: find f(g(x)) and g(f(x)) for f(x) = 3x − 1 and g(x) = 2x + 1.
1 Find f(g(x))
f(g(x)) is a function inside a function.
Like with brackets, we start inside.
First g(x).
g(x) is 2x + 1.
So f(g(x)) is f(2x + 1).
Put (2x + 1) in place of every x in f.
We keep it in brackets.
The 3 in front of the bracket multiplies every part inside.
So we write 3 times each part.
3 times 2x is 6x.
3 times 1 is 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.
3 − 1 is 2.
So the expression is 6x + 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 3x − 1.
So g(f(x)) is g(3x − 1).
Put (3x − 1) in place of every x in g.
We keep it in brackets.
The 2 in front of the bracket multiplies every part inside.
So we write 2 times each part.
Watch the signs.
2 times 3x is 6x.
2 times (−1) is −2.
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.
−2 + 1 is −1.
So the expression is 6x − 1.
3 Compare
6x + 2 and 6x − 1 are not the same.
So the order matters!
Careful!
Inside first, then outside.
Swap them, and you usually get a different rule.
4 Check
Let's check with a number: x = 1.
g of 1 is 3, then f of 3 is 8.
f of 1 is 2, then g of 2 is 5.
Different, as we found.
And our rules give the same numbers: 6x + 2 gives 8, 6x − 1 gives 5.
They are right!
Let's look back.
First: find f(g(x)).
Then: find g(f(x)).
Then: compare.
Last: check.