Skip to content

Composition of Functions

Definition

Let f ⁣:X→Yf\colon X\to Y and g ⁣:W→Zg\colon W\to Z be functions, and suppose that the range of ff is contained in the domain WW of g.g\text{.} We define the composition g∘f ⁣:X→Zg\circ f\colon X\to Z by

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

Interpretation

Composition of functions describes how two functions can be combined so that the output of one becomes the input of the other. The composite g∘fg\circ f is read from right to left: first apply ff, then apply gg to the result.

Three sets X, W and Z with arrows f from X to W and g from W to Z; a point x goes to f(x) and then to g(f(x)), and a long arrow from X to Z shows the composite g after f.

The figure follows a single point: ff sends x∈Xx\in X to f(x)∈Wf(x)\in W, and gg sends that point on to g(f(x))∈Zg(f(x))\in Z. The long arrow underneath skips the middle step and is the composite g∘f ⁣:X→Zg\circ f\colon X\to Z. Both arrows out of WW end at the same point of ZZ, which is allowed: neither gg nor g∘fg\circ f has to be injective.

The condition that the range of ff lies in the domain of gg makes g(f(x))g(f(x)) meaningful for every xx. With f(x)=x−1f(x)=x-1 on R\mathbb{R} and g(y)=yg(y)=\sqrt{y}, the composite x−1\sqrt{x-1} only makes sense for x≥1x\ge1, so ff must first be taken on [1,∞)[1,\infty). Order matters as well: with f(x)=x2f(x)=x^2 and g(y)=sin⁡yg(y)=\sin y, (g∘f)(x)=sin⁡(x2)(g\circ f)(x)=\sin(x^2) but (f∘g)(x)=(sin⁡x)2(f\circ g)(x)=(\sin x)^2, and at x=πx=\pi the first is sin⁡(π2)≈−0.43\sin(\pi^2)\approx-0.43 while the second is 00. A bijection composed with its inverse gives the identity function.

A common slip is to read g∘fg\circ f as the product g⋅fg\cdot f. In the second Example (g∘f)(x)=2(x+1)(g\circ f)(x)=2(x+1), whereas g(x)f(x)=2x(x+1)g(x)f(x)=2x(x+1). Later, the chain rule gives the derivative of a composite.


Key Results

  • The composition g∘fg\circ f is defined when every output of ff lies in the domain of g,g\text{,} that is, when the range of ff is contained in the domain of g.g\text{.}
  • The actual condition is f(X)⊆Wf(X)\subseteq W, not equality of the declared middle sets Y=WY=W. Self-composition f∘ff\circ f on all of XX requires f(X)⊆Xf(X)\subseteq X.
  • Order matters: in general, g∘fg\circ f and f∘gf\circ g are different, and one may be defined even when the other is not.
  • Composition preserves many structural properties, such as continuity and differentiability, under suitable conditions.

Examples

  • If f(x)=x2f(x)=x^2 and g(y)=sin⁡y,g(y)=\sin y\text{,} then (g∘f)(x)=sin⁡(x2).(g\circ f)(x)=\sin(x^2)\text{.}
  • If f(x)=x+1f(x)=x+1 and g(y)=2y,g(y)=2y\text{,} then (g∘f)(x)=2(x+1).(g\circ f)(x)=2(x+1)\text{.}

Prerequisites

Sources

Aliases: function composition, composite function Symbols: element of, infinity, pi, real numbers, square root, subset

Last updated: 27 October 2026 11:52