Some processes happen in stages. Convert a temperature from Celsius to Fahrenheit, then from Fahrenheit to Rankine. Apply a discount to a price, then add tax to the result. Each stage is a function, and the stages chain together — the output of one becomes the input of the next.
This chaining is composition. Given functions f and g, the composition f∘g applies g first, then feeds the result into f. The output of g becomes the input of f, creating a single combined process from two separate ones.
What is Function Composition
Function composition connects two functions in sequence: the output of the first becomes the input of the second. The result is a new function that combines both operations.
If g takes an input x and produces g(x), and f then takes g(x) and produces f(g(x)), the composition f∘g captures this two-step process as a single function:
(f∘g)(x)=f(g(x))
The function g acts first, transforming the original input. The function f acts second, transforming the intermediate result. The final output depends on both functions working in sequence.
Composition differs fundamentally from arithmetic. Adding functions combines their outputs at the same input: (f+g)(x)=f(x)+g(x). Composing functions chains their operations: (f∘g)(x)=f(g(x)). The input to f in composition is not x but g(x).
Composition creates new functions with potentially different domains, ranges, and properties than either component.
Notation for Composition
Several notations express the same composition:
(f∘g)(x)=f(g(x))
The symbol ∘ denotes composition. Read f∘g as "f composed with g" or "f of g."
The notation f(g(x)) shows the structure explicitly: g(x) is computed first, then f is applied to that result. The inner function g acts first; the outer function f acts second.
Some texts write fg(x) without the composition symbol, relying on context to distinguish from multiplication. This notation risks confusion and is best avoided unless the meaning is clear.
The order in the notation matters critically. In f∘g, the function g appears on the right but acts first. The function f appears on the left but acts second. This right-to-left reading matches the nested parentheses in f(g(x)): evaluate from the inside out.
When speaking aloud, "f of g of x" follows the written order while preserving the evaluation sequence: start with x, apply g, then apply f.
Evaluating Compositions at a Point
To find (f∘g)(a) for a specific input a, work from the inside out:
Step 1: Evaluate the inner function: compute g(a).
Step 2: Evaluate the outer function at that result: compute f(g(a)).
Let f(x)=x2+1 and g(x)=3x−2. Find (f∘g)(4).
Step 1: g(4)=3(4)−2=10
Step 2: f(10)=102+1=101
Therefore (f∘g)(4)=101.
Now find (g∘f)(4) — the composition in the opposite order.
Step 1: f(4)=42+1=17
Step 2: g(17)=3(17)−2=49
Therefore (g∘f)(4)=49.
The two results differ: 101=49. The order of composition matters — f∘g and g∘f are generally different functions.
Finding Composite Functions Algebraically
To find the formula for (f∘g)(x), substitute the entire expression for g(x) into f wherever f has its input variable.
Let f(x)=x2−4 and g(x)=2x+1. Find (f∘g)(x).
Start with f(x)=x2−4. Replace every x with g(x)=2x+1:
f(g(x))=(2x+1)2−4
Expand and simplify:
(2x+1)2−4=4x2+4x+1−4=4x2+4x−3
So (f∘g)(x)=4x2+4x−3.
Now find (g∘f)(x). Start with g(x)=2x+1. Replace x with f(x)=x2−4:
g(f(x))=2(x2−4)+1=2x2−8+1=2x2−7
So (g∘f)(x)=2x2−7.
The two composite functions are different, confirming that composition is not commutative.
Domain of Composite Functions
The domain of a composite function f∘g is not simply the intersection of the two domains. Two conditions must be satisfied:
1. x must be in the domain of g — the inner function must be able to process the input.
2. g(x) must be in the domain of f — the output of g must be a valid input for f.
Let f(x)=x with domain [0,∞) and g(x)=x−3 with domain (−∞,∞).
For (f∘g)(x)=x−3:
Condition 1: g accepts all real x — no restriction here.
Condition 2: f requires g(x)≥0, so x−3≥0, meaning x≥3.
The domain of f∘g is [3,∞).
Let f(x)=1/x with domain x=0 and g(x)=x2−1.
For (f∘g)(x)=x2−11:
Condition 1: g accepts all real x.
Condition 2: f requires g(x)=0, so x2−1=0, meaning x=±1.
The domain of f∘g is {x:x=−1 and x=1}.
Non-Commutativity
Composition is not commutative: f∘g does not generally equal g∘f. The order of the functions determines the result.
Let f(x)=x+5 and g(x)=x2.
(f∘g)(x)=f(g(x))=f(x2)=x2+5
(g∘f)(x)=g(f(x))=g(x+5)=(x+5)2=x2+10x+25
These are different functions with different graphs and different values at most inputs. Only at specific points might they coincide by accident.
Non-commutativity reflects the asymmetry of chained processes. Converting Celsius to Fahrenheit, then to Rankine produces a different result than converting Celsius to Rankine, then to Fahrenheit — if such a path even made sense.
In rare cases, f∘g=g∘f. When both functions are linear with the same slope but different intercepts, for example, or when one function is the identity. But these are special cases, not the general rule.
Composing More Than Two Functions
Composition extends to three or more functions. The principle remains the same: evaluate from the innermost function outward.
For three functions f, g, and h:
(f∘g∘h)(x)=f(g(h(x)))
The function h acts first on x, producing h(x). Then g acts on that result, producing g(h(x)). Finally f acts, producing f(g(h(x))).
Let f(x)=x2, g(x)=x+1, and h(x)=2x. Find (f∘g∘h)(3).
Step 1: h(3)=6
Step 2: g(6)=7
Step 3: f(7)=49
So (f∘g∘h)(3)=49.
The algebraic formula:
h(x)=2x
g(h(x))=2x+1
f(g(h(x)))=(2x+1)2=4x2+4x+1
Composition is associative: (f∘g)∘h=f∘(g∘h). Grouping does not affect the result, though order still matters.
Composition with Itself
A function can be composed with itself. The notation f∘f means applying f twice in succession, and (f∘f)(x)=f(f(x)).
Let f(x)=2x. Then:
f(f(x))=f(2x)=2(2x)=4x
Applying f twice multiplies by 4. Applying three times gives f(f(f(x)))=8x. Each application doubles the input.
Let f(x)=x2. Then:
f(f(x))=f(x2)=(x2)2=x4
Squaring twice yields the fourth power.
The notation f2 sometimes denotes f∘f, meaning f composed with itself — not f squared as a multiplication. Context determines the meaning. When clarity is needed, write f∘f or f(f(x)) explicitly.
Iterated composition leads to sequences and dynamical systems. Starting with x0, define x1=f(x0), x2=f(x1)=f(f(x0)), and so on. The behavior of these iterates reveals long-term dynamics of the function.
Decomposing Functions
Decomposition reverses composition: given a function h, express it as h=f∘g for simpler functions f and g.
Consider h(x)=x2+1. This function squares the input, adds one, then takes the square root. Identify the inner and outer operations:
Inner function: g(x)=x2+1
Outer function: f(x)=x
Check: f(g(x))=f(x2+1)=x2+1=h(x). ✓
Consider h(x)=(3x−7)5. The structure is: form 3x−7, then raise to the fifth power.
Inner function: g(x)=3x−7
Outer function: f(x)=x5
Check: f(g(x))=(3x−7)5=h(x). ✓
Decomposition is not unique. The function h(x)=(x+1)2 can be written as f∘g with f(x)=x2 and g(x)=x+1, or as f∘g with f(x)=(x+1)2 and g(x)=x (trivial decomposition). Choose the decomposition that serves the purpose — simplifying analysis, enabling substitution in calculus, or revealing structure.
Composition and Inverse Functions
Composition provides the defining property of inverse functions. If f−1 is the inverse of f, then:
(f∘f−1)(x)=f(f−1(x))=x
(f−1∘f)(x)=f−1(f(x))=x
Each composition yields the identity function — the function that returns its input unchanged.
Let f(x)=2x+3 and f−1(x)=2x−3. Verify:
f(f−1(x))=f(2x−3)=2⋅2x−3+3=(x−3)+3=x✓
f−1(f(x))=f−1(2x+3)=2(2x+3)−3=22x=x✓
This verification method confirms that two functions are inverses. If either composition fails to produce x, the functions are not inverses.
The identity function I(x)=x is the compositional equivalent of the number 1 in multiplication: f∘I=I∘f=f for any function f. Inverses compose to produce this neutral element.
Graphical Composition
Composing functions graphically requires reading values from two graphs in sequence.
To find (f∘g)(a) from graphs of f and g:
Step 1: On the graph of g, locate x=a on the horizontal axis. Read the corresponding y-value; this is g(a).
Step 2: On the graph of f, locate x=g(a) on the horizontal axis. Read the corresponding y-value; this is f(g(a))=(f∘g)(a).
The output of g becomes the input for f. Each composition evaluation requires two graph readings.
Building the entire graph of f∘g from graphs of f and g is labor-intensive. For each x-value, perform the two-step reading. The result is a new curve whose shape depends on both component functions.
Graphical composition is most useful for specific point evaluations or for understanding conceptually how the functions interact. For detailed graphing, algebraic methods are more efficient.
Applications of Composition
Composition models processes that occur in stages, where the output of one stage feeds into the next.
Unit conversions often chain. To convert Celsius to Kelvin, add 273.15. To convert Kelvin to Rankine, multiply by 1.8. The composition converts Celsius directly to Rankine:
R(C)=1.8(C+273.15)=1.8C+491.67
Pricing calculations chain. A 20% discount applies first: g(p)=0.8p. Then 8% tax applies: f(x)=1.08x. The final price:
f(g(p))=1.08(0.8p)=0.864p
The order matters: tax on the discounted price differs from discount on the taxed price.
Growth models chain. If population depends on resources, and resources depend on time, then population depends on time through composition.
In each case, composition captures the sequential nature of the process. The intermediate quantity — Kelvin, discounted price, resource level — may never be explicitly calculated, but it mediates the relationship between initial input and final output.