Skip to content
One hour with George, then a written plan the next working day. Book yours.

Composition and inverse functions

A function sends each input to exactly one output. Two ideas follow from that definition and drive most function problems: you can compose functions by feeding one output into another, and some functions can be reversed. Composition is associative but not commutative, and a function has an inverse only if it never gives the same output for two different inputs.

For students and parents planning test prep or coursework: one hour with George Li, one to one by video, is $180, $200 or $160, by subject. You leave with a written plan within one working day.

Book your first session
Composing f(x) = 2x + 3 with g(x) = x squared in both orders
CompositionFormulaValue at x = 2
f of g, written f(g(x))2(x squared) + 3 = 2x squared + 32(4) + 3 = 11
g of f, written g(f(x))(2x + 3) squared = 4x squared + 12x + 97 squared = 49

The same two functions give different compositions, which is why order matters.

Computed by hand and confirmed by evaluating both compositions at x = 2 in code

What are the properties of composition?

  • It is not commutative: f of g and g of f are usually different functions, as the table shows.
  • It is associative: (f of g) of h equals f of (g of h), so a chain of three can be grouped either way.
  • The identity function, I(x) = x, leaves any function unchanged when composed with it on either side.
  • The domain of f of g is the set of x in the domain of g for which g(x) is in the domain of f. A step can drop an input even if the final formula looks harmless.

Work compositions from the inside out. To find f(g(2)) with the functions above, compute g(2) = 4 first, then f(4) = 11.

What is an inverse function?

The inverse of f, written f inverse, undoes f. If f(a) = b, then f inverse of b is a. Two facts follow from that. Composing a function with its inverse in either order returns the starting input, so f(f inverse(x)) = x and f inverse of (f(x)) = x. And the domain and range swap: the domain of f inverse is the range of f, and the range of f inverse is the domain of f. That second fact is a handy way to find a range, since you can find the domain of the inverse instead.

The notation f inverse of x does not mean 1 / f(x). The reciprocal of a function is a different function.

When does an inverse exist?

Only when f is one-to-one: no two different inputs give the same output. On a graph, this is the horizontal line test, which says no horizontal line crosses the graph more than once. The function x squared fails because 2 and -2 both give 4, so its inverse as a function does not exist unless you restrict the domain, for example to x at least 0. The graph of a function and the graph of its inverse are mirror images across the line y = x.

How do you find the inverse?

  1. Write the function as y = f(x).
  2. Swap x and y.
  3. Solve the new equation for y.
  4. Write the result as f inverse of x, and test it by composing.

Worked example: Inverse of a rational function, checked by composition

Find the inverse of f(x) = (2x + 1) / (x - 3), and state the domain of the inverse.

  1. Write y = (2x + 1) / (x - 3) and swap the variables: x = (2y + 1) / (y - 3).
  2. Multiply both sides by (y - 3): x(y - 3) = 2y + 1, so xy - 3x = 2y + 1.
  3. Collect the y terms on one side: xy - 2y = 3x + 1, so y(x - 2) = 3x + 1.
  4. Divide by (x - 2): y = (3x + 1) / (x - 2). So f inverse of x = (3x + 1) / (x - 2).
  5. The domain of f is all reals except 3, and the domain of f inverse is all reals except 2. By the swap rule, the range of f is all reals except 2.
  6. Check with x = 5: f(5) = 11/2, and f inverse of 11/2 = (16.5 + 1) / 3.5 = 5, which returns the start.

Answer: f inverse of x = (3x + 1) / (x - 2), with domain all reals except 2.

Source: Original example by George Li Tutoring; the inverse and both compositions were verified in code.

For a step-by-step method with more examples, read finding an inverse function. For the rule behind each domain, see the domain of each kind of function. For help with function notation in a course, see high school course tutoring or book a first session.

Common questions

Is function composition commutative?

No. f of g and g of f are usually different. Composition is associative, though.

How do you know whether a function has an inverse?

It has an inverse if it is one-to-one, which you can test with the horizontal line test.

Is the inverse of a function the same as its reciprocal?

No. The inverse undoes the function, and the reciprocal is 1 divided by the function.

How can an inverse help you get a function's range?

The range of f is the domain of f inverse. Find the inverse and read off its domain.

Sources