Mathematics.

functions

Composition of Functions

Algebra II30 minDifficulty3 out of 10

You should know: functions

Overview

Function composition chains two functions together so the output of one becomes the input of the next: (f∘g)(x) = f(g(x)). It's the algebraic way of describing a multi-step process — apply g first, then feed the result into f — and it's the operation whose 'undo' defines inverse functions (f∘f⁻¹ = identity).

Intuition

Think of an assembly line: g(x) is the first machine, transforming the raw input; f then takes g's output and transforms it further. The composite (f∘g)(x) describes the entire two-step pipeline as a single function. Order matters — running g then f is generally not the same as running f then g, just as putting on socks then shoes gives a different (sensible) result than shoes then socks.

Interactive Graph

sin(x^2) — a composition of two functions

Loading visualization…

Formal Definition

Definition

The composition of f and g, read 'f composed with g' or 'f of g', applies g first and then f:

(fg)(x)=f(g(x))(f\circ g)(x) = f(g(x))
Composition
dom(fg)={xdom(g):g(x)dom(f)}\text{dom}(f\circ g) = \{x \in \text{dom}(g) : g(x) \in \text{dom}(f)\}

x must be valid for g, and g(x) must be valid for f

Properties

Non-commutativity

fggf in generalf\circ g \neq g \circ f \text{ in general}

Associativity

f(gh)=(fg)hf\circ(g\circ h) = (f\circ g)\circ h

Identity element

fid=idf=ff\circ \text{id} = \text{id}\circ f = f

Inverse composition

ff1=f1f=id, when f1 existsf\circ f^{-1} = f^{-1}\circ f = \text{id}, \text{ when } f^{-1} \text{ exists}

Applications

Function composition models pipelines and chained transformations in functional programming, where complex operations are built by composing simple ones.

Worked Examples

  1. First evaluate the inner function g(3).

    g(3)=32=9g(3) = 3^2 = 9
  2. Feed that result into f.

    f(g(3))=f(9)=2(9)+1=19f(g(3)) = f(9) = 2(9)+1 = 19

Answer: (f∘g)(3) = 19

Practice Problems

Difficulty 3/10

Given f(x)=3x-2 and g(x)=x+5, find (g∘f)(x) and confirm it differs from (f∘g)(x).

Difficulty 4/10

Given f(x)=1/x and g(x)=x-1, find the domain of (f∘g)(x).

Common Mistakes

Common Mistake

Assuming (f∘g)(x) is the same as f(x)·g(x).

Composition means substituting g(x) as the ENTIRE input to f, not multiplying the two functions. (f∘g)(x)=f(g(x)) is generally very different from the product f(x)g(x).

Common Mistake

Ignoring domain restrictions introduced by the composition.

Even if f and g individually have simple domains, (f∘g)(x) can have a smaller domain — you must exclude any x where g(x) falls outside f's domain, in addition to excluding x outside g's own domain.

Summary

  • (f∘g)(x) = f(g(x)) applies g first, then feeds its output into f.
  • Composition is generally NOT commutative: f∘g ≠ g∘f.
  • Composition IS associative: f∘(g∘h) = (f∘g)∘h.
  • The domain of f∘g requires x to be valid for g AND g(x) to be valid for f.
  • A function composed with its inverse returns the identity: f∘f⁻¹ = f⁻¹∘f = x.

References

  1. BookSullivan, M. Algebra and Trigonometry, 10th ed. Ch. 2 — Functions and Their Graphs.