Steply

f(x) = 3x, g(x) = x - 4, find f(g(x)) and g(f(x))

Step by step, with the reason for every step · Composition order · Algebra 2

Step by step

The question

Question: find f(g(x)) and g(f(x)) for f(x) = 3x and g(x) = x − 4.

f(x) = 3x
g(x) = x − 4

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 − 4.

So f(g(x)) is f(x − 4).

f(g(x)) = f(x − 4)

Put (x − 4) in place of every x in f.

We keep it in brackets.

= 3(x − 4)

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(−4)
− × + = −

Watch the signs.

3 times x is 3x.

3 times (−4) is −12.

f(g(x)) = 3x − 12

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.

So g(f(x)) is g(3x).

g(f(x)) = g(3x)

Put (3x) in place of every x in g.

We keep it in brackets.

= (3x) − 4

A bracket with a plus or nothing in front can just be removed.

( ) away

Now we have 3x − 4.

g(f(x)) = 3x − 4

3 Compare

3x − 12 and 3x − 4 are not the same.

So the order matters!

3x − 12 ≠ 3x − 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 −3, then f of −3 is −9.

f(g(1)) = f(−3) = −9

f of 1 is 3, then g of 3 is −1.

Different, as we found.

g(f(1)) = g(3) = −1

And our rules give the same numbers: 3x − 12 gives −9, 3x − 4 gives −1.

They are right!

3x − 12 → −9, 3x − 4 → −1

Let's look back.

First: find f(g(x)).

Then: find g(f(x)).

Then: compare.

Last: check.

Answer
3x − 12 ≠ 3x − 4

Your turn

Try this one yourself, then check:

f(x) = 2x, g(x) = 4x − 1, find f(g(x)) and g(f(x))
Show the answer
8x − 2 ≠ 8x − 1

More from Composition order

The whole lesson: Composition order →