Step by step
The question
Question: find f(g(x)) and g(f(x)) for f(x) = x² + 2 and 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).
g(x) is x + 1.
So f(g(x)) is f(x + 1).
Put (x + 1) in place of every x in f.
We keep it in brackets.
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.
So we write the bracket two times.
Each part of the first bracket multiplies the whole second bracket.
The parts of the first bracket are x and 1.
Each one takes the whole second bracket.
What is in front of a bracket multiplies every part inside.
So we write each part times what is in front.
x times x is x².
x times 1 is x.
1 times x is x.
1 times 1 is 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.
Plain numbers go together.
Each colour is one kind.
x + x is 2x.
It is like 1 apple plus 1 apple: that is 2 apples.
1 + 2 is 3.
So the expression is x² + 2x + 3.
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).
Put (x² + 2) in place of every x in g.
We keep it in brackets.
A bracket with a plus or nothing in front can just be removed.
Now we have x² + 2 + 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.
2 + 1 is 3.
So the expression is x² + 3.
3 Compare
x² + 2x + 3 and x² + 3 are not the same.
So the order matters!
4 Check
Let's check with a number: x = 1.
g of 1 is 2, then f of 2 is 6.
f of 1 is 3, then g of 3 is 4.
Different, as we found.
And our rules give the same numbers: x² + 2x + 3 gives 6, x² + 3 gives 4.
They are right!
Let's look back.
First: find f(g(x)).
Then: find g(f(x)).
Then: compare.
Last: check.