Algebra 2 · Functions and transformations

Composing functions

Feeding one function’s output into another — and the order matters.

Two functions, two orders

Square 2 and add 3, or add 3 and then square: one route gives 7 and the other 25. The notation f(g(2)) tells you which route to take — but you have to read it in the opposite order from the way it is written.

Composition applies one function to the result of another. The notation reads from the inside out, which is the reverse of the order the letters are written in, and that is where the errors live.

(f \circ g)(x) = f(g(x))

Two worked examples

Example 1 — inside first

  1. With f(x) = x^2 and g(x) = x + 3.
  2. Compute f(g(2)): the inner function first. g(2) = 5
  3. Then feed that into the outer one. f(5) = 25
  4. So f(g(2)) = 25.

Example 2 — the order is not free

  1. Now compute g(f(2)) with the same two functions.
  2. The inner one first. f(2) = 4
  3. Then the outer. g(4) = 7
  4. So g(f(2)) = 7, and f(g(2)) = 25.
  5. Composition is not commutative, and the gap here is not small.
In every pair the two orders give different results: the function touching x acts first.