Step by step
The question
Question: find f(g(x)) and g(f(x)) for f(x) = x + 6 and g(x) = −2x.
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.
So f(g(x)) is f(−2x).
Put (−2x) in place of every x in f.
We keep it in brackets.
A bracket with a plus or nothing in front can just be removed.
Now we have −2x + 6.
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 + 6.
So g(f(x)) is g(x + 6).
Put (x + 6) 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 x is −2x.
(−2) times 6 is −12.
3 Compare
−2x + 6 and −2x − 12 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 −2, then f of −2 is 4.
f of 1 is 7, then g of 7 is −14.
Different, as we found.
And our rules give the same numbers: −2x + 6 gives 4, −2x − 12 gives −14.
They are right!
Let's look back.
First: find f(g(x)).
Then: find g(f(x)).
Then: compare.
Last: check.