Composing & Inverting Functions — Print

Functions can be bolted together end to end, and any chain can be run backwards.

What the practice questions cover

These questions use 3 ideas from the course. Follow any of them for a definition, where it is taught, and what it leads to.

Two vending machines, bolted together.

Feed 3 into the first. It doubles what it is given, so 6 comes out of the chute.

two machines, bolted together 3 double it g 6 add 5 f 11 the middle number never gets written down

That 6 drops straight into the second machine, which adds 5. You collect 11.

Nobody writes the 6 anywhere. The pair behaves as one machine that turns 3 into 11.

That is composition. Written f(g(3)), the inner machine runs first — which is why the notation reads inside-out, and why the order cannot be swapped.

A function machine multiplying by three then adding two 4 input x ×3, then +2 f(x) = 3x + 2 the rule 14 output y one input in, exactly one output out — that is what makes it a function

Combining functions the plain way

You can add, subtract, multiply and divide functions the same way you do numbers: (f+g)(x) just means f(x) + g(x).

Do each one separately, then combine. There is no trick here, and no new rule to learn.

The only care needed is division: fg is undefined wherever g(x) = 0, so those inputs leave the domain.

Evaluate first, combine second

For (f · g)(4), find f(4) and g(4) as numbers and multiply them. Multiplying the formulas first is more work and more chances to slip.

Composition: one machine feeds the other

(f ° g)(x) means f(g(x)). Work from the inside out, exactly as you would with brackets in arithmetic.

With g(x) = 2x and f(x) = x + 5: g(3) = 6 first, then f(6) = 11.

To get a formula rather than a number, substitute the whole inner expression: f(g(x)) = 2x + 5.

Inside-out, not left to right

In f(g(x)) the function nearest the x runs first. Reading it left to right gives you the other composition, and the two are almost never the same.

Why the order matters

Double then add five, starting from 3, gives 11. Add five then double gives 16. Same two machines, different answers.

So f ° g and g ° f are different functions, and asking which one a problem wants is half the work.

Put your socks on before your shoes. Composition has the same kind of order, and the same consequences for getting it wrong.

A quick test

Pick any number, say 2, and run it both ways. If the two answers differ, the compositions differ — and now you know which is which.

Inverses: running the chain backwards

An inverse takes each output back to the input it came from. If f(3) = 11, then f-1(11) = 3.

To find the formula, swap x and y and solve for y. Swapping is what reverses the roles of input and output.

From y = 2x + 5: swap to x = 2y + 5, then y = x - 52. That is f-1.

The graph gives it away

A function and its inverse are mirror images across the line y = x. Swapping x and y is that reflection, written algebraically.

Not every function can be undone

f(x) = x2 sends both 3 and -3 to 9. Asked to undo 9, the inverse would not know which one to return.

A function has an inverse only when it is one-to-one, and the horizontal line test checks exactly that.

That is why √x is defined as the nonnegative root only, and why the domain of x2 is often restricted to x ≥ 0.

The check that settles it

Two functions are inverses when f(g(x)) = x and g(f(x)) = x. Both directions are needed — one alone can hold by accident.

Worked examples

A composition, as a number

For f(x) = x2 - 1 and g(x) = 3x + 2, find (f ° g)(1).

  1. Innermost first: g(1) = 3(1) + 2 = 5. The function next to the 1 runs first.
  2. Now feed that into f: f(5) = 52 - 1 = 24. The output of g becomes the input of f.
  3. So (f ° g)(1) = 24. Reading it left to right would give f(1) = 0 then g(0) = 2 — a different question.

24

A composition, as a formula

For f(x) = x2 - 1 and g(x) = 3x + 2, find (f ° g)(x).

  1. Replace every x in f with the whole of g(x): (3x + 2)2 - 1. The inner expression travels as one block, so it needs brackets.
  2. Expand: (3x+2)2 = 9x2 + 12x + 4. Square the binomial, do not square the terms separately.
  3. So (f ° g)(x) = 9x2 + 12x + 3. Check with x = 1: 9 + 12 + 3 = 24, matching the previous example.

9x2 + 12x + 3

Finding an inverse

Find the inverse of f(x) = x + 43.

  1. Write y = x+43, then swap: x = y+43. Swapping exchanges input and output, which is what an inverse does.
  2. Multiply both sides by 3: 3x = y + 4. Undo the division first, because it was applied last.
  3. Subtract 4: y = 3x - 4, so f-1(x) = 3x - 4. Check: f(5) = 3 and f-1(3) = 5.

f-1(x) = 3x - 4

Words to know

Composition
Running one function on the output of another, written (f ° g)(x) = f(g(x)).
Inverse function
The function that undoes another, written f-1. It sends every output back to the input it came from.
One-to-one
No two inputs share an output. Only a one-to-one function has an inverse that is itself a function.
Horizontal line test
If any horizontal line meets a graph twice, the function is not one-to-one.
Domain of a composition
The inputs that survive both machines — the inner function must produce something the outer one accepts.

Mistakes to watch for

Composing in the wrong order. f(g(x)) runs g first, because g is the one touching the x. Reading left to right gives g(f(x)), a genuinely different function — with f(x)=x+5 and g(x)=2x the two differ by 5 at every input.

Dropping the brackets when substituting. f(x) = x2 composed with g(x) = x+1 is (x+1)2, not x2 + 1. The inner function arrives as a single block, and a block being squared needs to be held together.

Reading f-1 as a reciprocal. f-1(x) is the inverse function, not 1f(x). For f(x) = 2x the inverse is x2 while the reciprocal is 12x — they agree nowhere except by accident.

Claiming an inverse for a function that has none. f(x) = x2 fails the horizontal line test, so undoing 9 is ambiguous. Without a restricted domain there is no inverse function to find.

Checking only one direction. f(g(x)) = x on its own is not enough; g(f(x)) = x must hold too. A one-sided check can pass for functions that are not inverses on the full domain.

The ° in f ° g was introduced so nobody had to keep writing nested brackets. It is read "after": f after g.

Composition is how almost all software is built. A photo filter is a dozen small functions, each handed the output of the last.

Inverse functions are why you can undo a spreadsheet formula, and why encryption works: some functions are easy forwards and brutal backwards.

Problem 1

For f(x)=2x+1 and g(x)=x-4, find (f+g)(3).

Worked answer

6

f(3)=2(3)+1=7

g(3)=3-4=-1

7+(-1)=6

Problem 2

For f(x)=x2 and g(x)=3x, find (f+g)(2).

Worked answer

10

f(2)=4

g(2)=6

4+6=10

Problem 3

For f(x)=x+5 and g(x)=x-2, find (fg)(4).

Worked answer

18

f(4)=9

g(4)=2

9 × 2 = 18

Problem 4

For f(x)=x+3 and g(x)=2x, find f(g(5)).

Worked answer

13

g(5)=10

f(10)=13

Problem 5

For f(x)=x2 and g(x)=x-1, find f(g(4)).

Worked answer

9

g(4)=3

f(3)=9

Problem 6

For f(x)=2x-1 and g(x)=x2+1, find (f ° g)(2).

Worked answer

9

g(2)=5

f(5)=2(5)-1=9

Problem 7

For f(x)=x+4 and g(x)=3x, find g(f(2)).

Worked answer

18

f(2)=6

g(6)=18

Note f(g(2))=10 — the order matters

Problem 8

For f(x)=x2 and g(x)=x+3, write f(g(x)) expanded.

Worked answer

x^2+6x+9

f(g(x))=(x+3)2

=x2+6x+9

Problem 9

For f(x)=3x-2 and g(x)=x+1, write (f ° g)(x) simplified.

Worked answer

3x+1

3(x+1)-2

=3x+3-2=3x+1

Problem 10

Find the inverse of f(x)=x+7.

Worked answer

x-7

y=x+7, swap: x=y+7

y=x-7

Problem 11

Find the inverse of f(x)=4x.

Worked answer

x/4

U

n

d

o

t

h

e

m

u

l

t

i

p

l

i

c

a

t

i

o

n

.

Problem 12

Find the inverse of f(x)=2x-6.

Worked answer

(x+6)/2

S

w

a

p

,

t

h

e

n

u

n

d

o

i

n

r

e

v

e

r

s

e

o

r

d

e

r

.

Problem 13

Which function has an inverse that is also a function?

  1. f(x)=x2
  2. f(x)=|x|
  3. f(x)=x3
  4. f(x)=x2+1
Worked answer

f(x)=x3

x2 and |x| both send two inputs to one output

x3 is one-to-one — it never repeats a value

So only x3 can be undone

Problem 14

If f(x)=5x-3, find f-1(12).

Worked answer

3

5x-3=12

5x=15

x=3

Problem 15

For f(x)=1x and g(x)=x-2, which x must be excluded from f(g(x))?

Worked answer

2

f(g(x))=1x-2

The bottom is zero when x=2

Problem 16

For f(x)=x2-3, find f(f(2)).

Worked answer

-2

f(2)=4-3=1

f(1)=1-3=-2

Browse all courses