Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Composition






Functions Within Functions

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 ff and gg, the composition f∘gf \circ g applies gg first, then feeds the result into ff. The output of gg becomes the input of ff, creating a single combined process from two separate ones.

Key Terms

Core

Composition of Functions— (f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x)), output of gg becomes input of ff
Inverse Function— composing a function with its inverse yields the identity: f(f−1(x))=xf(f^{-1}(x)) = x

Supporting

Function— the building blocks being chained
Domain— the domain of f∘gf \circ g requires xx in the domain of gg and g(x)g(x) in the domain of ff
One-to-One Function— required for a function to have an inverse, which composition can verify


See All Function Definitions →


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 gg takes an input xx and produces g(x)g(x), and ff then takes g(x)g(x) and produces f(g(x))f(g(x)), the composition f∘gf \circ g captures this two-step process as a single function:

Composition of Functions
(f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x))
Learn more about this formula: Composition of Functions →


The function gg acts first, transforming the original input. The function ff 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)(f + g)(x) = f(x) + g(x). Composing functions chains their operations: (f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x)). The input to ff in composition is not xx but g(x)g(x).

Composition creates new functions with potentially different domains, ranges, and properties than either component.
-10-5510-55f(g(x)) = (sin x)²g(f(x)) = sin(x²)
f(x) = x², g(x) = sin x: f(g(x)) = (sin x)²

The output of the inner function feeds the outer one: every value sin x is squared, so the composite curve is the sine wave with its negative halves folded up. Swap the order and g(f(x)) = sin(x²) is a wave that speeds up as x grows; the two composites are different functions. Compare the two orders for any pair on the function composition explorer.

The order of the two functions is part of the definition, not a detail.

Composition Notation

Notation

Composition Notation

One operation, three spellings: the ring, the nested parentheses, and the juxtaposition some texts risk. The order rule — right side acts first — is the whole game, and all three forms appear among the function symbols.
f(x)f(x), the letter conventions and substitution come from function notation; the domain restrictions a composition inherits are written with domain notation.
f∘gf \circ g
f composed with g; f after g
The hollow ring is the composition operator: f∘gf \circ g is one new function, built by feeding gg's output to ff. Read right-to-left — gg sits second but acts first; "f after g" is the reading that encodes the order.
CasesIterates hide the ring: in dynamics f2f^2 means f∘ff \circ f — while the squared shorthand sin⁡2θ\sin^2\theta squares the value; the superscript's meaning flips by field, so careful texts write f∘ff \circ f out.
Do not confuseThe multiplication dot. f∘gf \circ g and f⋅gf \cdot g differ by hollowness alone — one chains rules, the other multiplies outputs; and the ring is not the degree mark °°, which rides superscript on a number.
f(g(x))f(g(x))
f of g of x
The self-explaining spelling: nesting shows the order — evaluate inside out, g(x)g(x) first, then ff of the result. (f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x)) is the bridge between the two forms.
CasesAt a point the nesting becomes a two-step computation — (f∘g)(4)(f \circ g)(4) runs g(4)g(4) then ff of it, the drill of Evaluating Compositions at a Point below; spoken aloud, "f of g of x" preserves both order and sequence.
Do not confuseg(f(x))g(f(x)). Same letters, opposite machine — f∘gf \circ g and g∘fg \circ f are generally different functions, as the 101≠49101 \neq 49 example below demonstrates; the notation is order-critical.
fg(x)fg(x)
f g of x — ambiguous
The risky spelling: some texts drop the ring and juxtapose, trusting context to rule out multiplication. Best avoided in elementary work — the same string means the product in function arithmetic, where (fg)(x)=f(x)⋅g(x)(fg)(x) = f(x) \cdot g(x).
CasesWhere it is standard: operator theory and abstract algebra compose by juxtaposition routinely, because composition is the only product those settings have.
Do not confuseA product. fg(x)fg(x) read as f(x)⋅g(x)f(x) \cdot g(x) versus f(g(x))f(g(x)) — two different numbers from one string; the ring or the nest costs one symbol and removes the ambiguity entirely.

Evaluating Compositions at a Point

To find (f∘g)(a)(f \circ g)(a) for a specific input aa, work from the inside out:

Step 1: Evaluate the inner function: compute g(a)g(a).

Step 2: Evaluate the outer function at that result: compute f(g(a))f(g(a)).

Let f(x)=x2+1f(x) = x^2 + 1 and g(x)=3x−2g(x) = 3x - 2. Find (f∘g)(4)(f \circ g)(4).

Step 1: g(4)=3(4)−2=10g(4) = 3(4) - 2 = 10

Step 2: f(10)=102+1=101f(10) = 10^2 + 1 = 101

Therefore (f∘g)(4)=101(f \circ g)(4) = 101.

Now find (g∘f)(4)(g \circ f)(4) — the composition in the opposite order.

Step 1: f(4)=42+1=17f(4) = 4^2 + 1 = 17

Step 2: g(17)=3(17)−2=49g(17) = 3(17) - 2 = 49

Therefore (g∘f)(4)=49(g \circ f)(4) = 49.

The two results differ: 101≠49101 \neq 49. The order of composition matters — f∘gf \circ g and g∘fg \circ f are generally different functions.
(f o g)(4) = 101 and (g o f)(4) = 49(f ∘ g)(4)410101g3x − 2fx² + 1inner g first, then f(g ∘ f)(4)41749fx² + 1g3x − 2inner f first, then gWork from the inside out — and the order matters: 101 ≠ 49
Inside out, in both orders

The section's two evaluations side by side. For (f ∘ g)(4) the input goes through g first, 3(4) − 2 = 10, and that 10 is what f receives: 10² + 1 = 101. Swap the order and f acts first: 4² + 1 = 17, then g gives 3(17) − 2 = 49. Same two functions, same input, different results.

The middle value never appears in the answer, but it decides it: 10 in one order, 17 in the other.

Finding Composite Functions Algebraically

To find the formula for (f∘g)(x)(f \circ g)(x), substitute the entire expression for g(x)g(x) into ff wherever ff has its input variable.

Let f(x)=x2−4f(x) = x^2 - 4 and g(x)=2x+1g(x) = 2x + 1. Find (f∘g)(x)(f \circ g)(x).

Start with f(x)=x2−4f(x) = x^2 - 4. Replace every xx with g(x)=2x+1g(x) = 2x + 1:

f(g(x))=(2x+1)2−4f(g(x)) = (2x + 1)^2 - 4


Expand and simplify:

(2x+1)2−4=4x2+4x+1−4=4x2+4x−3(2x + 1)^2 - 4 = 4x^2 + 4x + 1 - 4 = 4x^2 + 4x - 3


So (f∘g)(x)=4x2+4x−3(f \circ g)(x) = 4x^2 + 4x - 3.

Now find (g∘f)(x)(g \circ f)(x). Start with g(x)=2x+1g(x) = 2x + 1. Replace xx with f(x)=x2−4f(x) = x^2 - 4:

g(f(x))=2(x2−4)+1=2x2−8+1=2x2−7g(f(x)) = 2(x^2 - 4) + 1 = 2x^2 - 8 + 1 = 2x^2 - 7


So (g∘f)(x)=2x2−7(g \circ f)(x) = 2x^2 - 7.

The two composite functions are different, confirming that composition is not commutative.

Domain of Composite Functions

The domain of a composite function f∘gf \circ g is not simply the intersection of the two domains. Formally:

Domain of a Composition
Dom(f∘g)={x∈Dom(g):g(x)∈Dom(f)}\text{Dom}(f \circ g) = \{x \in \text{Dom}(g) : g(x) \in \text{Dom}(f)\}
Learn more about this formula: Domain of a Composition →


Two conditions must be satisfied:

1. xx must be in the domain of gg — the inner function must be able to process the input.

2. g(x)g(x) must be in the domain of ff — the output of gg must be a valid input for ff.

Let f(x)=xf(x) = \sqrt{x} with domain [0,∞)[0, \infty) and g(x)=x−3g(x) = x - 3 with domain (−∞,∞)(-\infty, \infty).

For (f∘g)(x)=x−3(f \circ g)(x) = \sqrt{x - 3}:

Condition 1: gg accepts all real xx — no restriction here.

Condition 2: ff requires g(x)≥0g(x) \geq 0, so x−3≥0x - 3 \geq 0, meaning x≥3x \geq 3.

The domain of f∘gf \circ g is [3,∞)[3, \infty).

Let f(x)=1/xf(x) = 1/x with domain x≠0x \neq 0 and g(x)=x2−1g(x) = x^2 - 1.

For (f∘g)(x)=1x2−1(f \circ g)(x) = \dfrac{1}{x^2 - 1}:

Condition 1: gg accepts all real xx.

Condition 2: ff requires g(x)≠0g(x) \neq 0, so x2−1≠0x^2 - 1 \neq 0, meaning x≠±1x \neq \pm 1.

The domain of f∘gf \circ g is {x:x≠−1 and x≠1}\{x : x \neq -1 \text{ and } x \neq 1\}.

The table below collects these worked examples side by side so the two-condition structure stands out at a glance.
Composite (f ∘ g)(x) Condition 1: x in domain of g Condition 2: g(x) in domain of f Domain of f ∘ g
√(x − 3)   (f = √x, g = x − 3) all real x — no restriction need x − 3 ≥ 0, so x ≥ 3 [3, ∞)
1 ⁄ (x² − 1)   (f = 1 ⁄ x, g = x² − 1) all real x — no restriction need x² − 1 ≠ 0, so x ≠ ±1 (−∞, −1) ∪ (−1, 1) ∪ (1, ∞)

Non-Commutativity

Composition is not commutative: f∘gf \circ g does not generally equal g∘fg \circ f. The order of the functions determines the result.

Let f(x)=x+5f(x) = x + 5 and g(x)=x2g(x) = x^2.

(f∘g)(x)=f(g(x))=f(x2)=x2+5(f \circ g)(x) = f(g(x)) = f(x^2) = x^2 + 5

(g∘f)(x)=g(f(x))=g(x+5)=(x+5)2=x2+10x+25(g \circ f)(x) = g(f(x)) = g(x + 5) = (x + 5)^2 = x^2 + 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∘ff \circ g = g \circ 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.

The table below sets f∘gf \circ g and g∘fg \circ f side by side for this pair to make the asymmetry concrete.
Composition Substitution Simplified formula Value at x = 1
f ∘ g   (g acts first) f(g(x)) = f(x²) = (x²) + 5 x² + 5 6
g ∘ f   (f acts first) g(f(x)) = g(x + 5) = (x + 5)² x² + 10x + 25 36

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 ff, gg, and hh:

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


The function hh acts first on xx, producing h(x)h(x). Then gg acts on that result, producing g(h(x))g(h(x)). Finally ff acts, producing f(g(h(x)))f(g(h(x))).

Let f(x)=x2f(x) = x^2, g(x)=x+1g(x) = x + 1, and h(x)=2xh(x) = 2x. Find (f∘g∘h)(3)(f \circ g \circ h)(3).

Step 1: h(3)=6h(3) = 6

Step 2: g(6)=7g(6) = 7

Step 3: f(7)=49f(7) = 49

So (f∘g∘h)(3)=49(f \circ g \circ h)(3) = 49.

The algebraic formula:

h(x)=2xh(x) = 2x

g(h(x))=2x+1g(h(x)) = 2x + 1

f(g(h(x)))=(2x+1)2=4x2+4x+1f(g(h(x))) = (2x + 1)^2 = 4x^2 + 4x + 1


Composition is associative: grouping does not affect the result, though order still matters.

Composition Associativity
(f∘g)∘h=f∘(g∘h)(f \circ g) \circ h = f \circ (g \circ h)
Learn more about this formula: Composition Associativity →


Composition with Itself

A function can be composed with itself. The notation f∘ff \circ f means applying ff twice in succession, and (f∘f)(x)=f(f(x))(f \circ f)(x) = f(f(x)).

Let f(x)=2xf(x) = 2x. Then:

f(f(x))=f(2x)=2(2x)=4xf(f(x)) = f(2x) = 2(2x) = 4x


Applying ff twice multiplies by 44. Applying three times gives f(f(f(x)))=8xf(f(f(x))) = 8x. Each application doubles the input.

Let f(x)=x2f(x) = x^2. Then:

f(f(x))=f(x2)=(x2)2=x4f(f(x)) = f(x^2) = (x^2)^2 = x^4


Squaring twice yields the fourth power.

The notation f2f^2 sometimes denotes f∘ff \circ f, meaning ff composed with itself — not ff squared as a multiplication. Context determines the meaning. When clarity is needed, write f∘ff \circ f or f(f(x))f(f(x)) explicitly.

Iterated composition leads to sequences and dynamical systems. Starting with x0x_0, define x1=f(x0)x_1 = f(x_0), x2=f(x1)=f(f(x0))x_2 = f(x_1) = f(f(x_0)), and so on. The behavior of these iterates reveals long-term dynamics of the function.
-10-5510-55f(g(x)) = x⁴g(f(x)) = x⁴
f composed with itself

Applying the same rule twice gives a new curve, f(f(x)), drawn beside f: the second application acts on the outputs of the first. Repeating a function is how iteration and recursion begin. See how the shape changes with each extra application on the function composition explorer.

Composition with itself is the simplest case of iterating a rule.

Decomposing Functions

Decomposition reverses composition: given a function hh, express it as h=f∘gh = f \circ g for simpler functions ff and gg.

Consider h(x)=x2+1h(x) = \sqrt{x^2 + 1}. This function squares the input, adds one, then takes the square root. Identify the inner and outer operations:

Inner function: g(x)=x2+1g(x) = x^2 + 1

Outer function: f(x)=xf(x) = \sqrt{x}

Check: f(g(x))=f(x2+1)=x2+1=h(x)f(g(x)) = f(x^2 + 1) = \sqrt{x^2 + 1} = h(x). ✓

Consider h(x)=(3x−7)5h(x) = (3x - 7)^5. The structure is: form 3x−73x - 7, then raise to the fifth power.

Inner function: g(x)=3x−7g(x) = 3x - 7

Outer function: f(x)=x5f(x) = x^5

Check: f(g(x))=(3x−7)5=h(x)f(g(x)) = (3x - 7)^5 = h(x). ✓

Decomposition is not unique. The function h(x)=(x+1)2h(x) = (x + 1)^2 can be written as f∘gf \circ g with f(x)=x2f(x) = x^2 and g(x)=x+1g(x) = x + 1, or as f∘gf \circ g with f(x)=(x+1)2f(x) = (x + 1)^2 and g(x)=xg(x) = x (trivial decomposition). Choose the decomposition that serves the purpose — simplifying analysis, enabling substitution in calculus, or revealing structure.

The table below collects the worked decompositions covered above with their inner and outer parts and a verification step.
Composite h(x) Inner g(x) Outer f(x) Verify f(g(x))
√(x² + 1) x² + 1 √x √(x² + 1) ✓
(3x − 7)⁵ 3x − 7 x⁵ (3x − 7)⁵ ✓
(x + 1)² x + 1 x² (x + 1)² ✓

Composition and Inverse Functions

Composition provides the defining property of inverse functions. If f−1f^{-1} is the inverse of ff, then:

(f∘f−1)(x)=f(f−1(x))=x(f \circ f^{-1})(x) = f(f^{-1}(x)) = x


(f−1∘f)(x)=f−1(f(x))=x(f^{-1} \circ f)(x) = f^{-1}(f(x)) = x


Each composition yields the identity function — the function that returns its input unchanged.

Let f(x)=2x+3f(x) = 2x + 3 and f−1(x)=x−32f^{-1}(x) = \dfrac{x - 3}{2}. Verify:

f(f−1(x))=f(x−32)=2⋅x−32+3=(x−3)+3=x✓f(f^{-1}(x)) = f\left(\frac{x - 3}{2}\right) = 2 \cdot \frac{x - 3}{2} + 3 = (x - 3) + 3 = x \checkmark


f−1(f(x))=f−1(2x+3)=(2x+3)−32=2x2=x✓f^{-1}(f(x)) = f^{-1}(2x + 3) = \frac{(2x + 3) - 3}{2} = \frac{2x}{2} = x \checkmark


This verification method confirms that two functions are inverses. If either composition fails to produce xx, the functions are not inverses.

The identity function I(x)=xI(x) = x is the compositional equivalent of the number 11 in multiplication: f∘I=I∘f=ff \circ I = I \circ f = f for any function ff. Inverses compose to produce this neutral element.
-10-5510-55f(g(x)) = e^(ln x) = xg(f(x)) = ln(eˣ) = x
f(x) = eˆx, g(x) = ln x: f(g(x)) = x

Composed in either order the two curves collapse onto the line y = x: the logarithm undoes the exponential and the exponential undoes the logarithm, which is the defining property of an inverse pair drawn out. The only trace of the pair is the domain restriction x > 0 inherited from ln. Check any candidate pair the same way on the function composition explorer.

A pair that composes to the identity in both orders is inverse; one order alone is not enough.

Graphical Composition

Composing functions graphically requires reading values from two graphs in sequence.

To find (f∘g)(a)(f \circ g)(a) from graphs of ff and gg:

Step 1: On the graph of gg, locate x=ax = a on the horizontal axis. Read the corresponding yy-value; this is g(a)g(a).

Step 2: On the graph of ff, locate x=g(a)x = g(a) on the horizontal axis. Read the corresponding yy-value; this is f(g(a))=(f∘g)(a)f(g(a)) = (f \circ g)(a).

The output of gg becomes the input for ff. Each composition evaluation requires two graph readings.

Building the entire graph of f∘gf \circ g from graphs of ff and gg is labor-intensive. For each xx-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.
(f o g)(0) read from two graphsstep 1 · graph of g(x) = 3x − 2step 2 · graph of f(x) = x² + 1g(0) = −2input 0input −2f(−2) = 5output of g becomes the input of f(f ∘ g)(0) = f(g(0)) = f(−2) = 5
Two graph readings, one composition

To find (f ∘ g)(0) from graphs: on the graph of g, go from x = 0 to the curve and read g(0) = −2. That output is the next input — find −2 on the x-axis of f's graph, go up to the curve and read f(−2) = 5. Every point of f ∘ g takes this pair of readings.

If g(a) falls outside the part of f's graph you can see — or outside f's domain — the composition cannot be read there.

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.15273.15. To convert Kelvin to Rankine, multiply by 1.81.8. The composition converts Celsius directly to Rankine:

R(C)=1.8(C+273.15)=1.8C+491.67R(C) = 1.8(C + 273.15) = 1.8C + 491.67


Pricing calculations chain. A 20%20\% discount applies first: g(p)=0.8pg(p) = 0.8p. Then 8%8\% tax applies: f(x)=1.08xf(x) = 1.08x. The final price:

f(g(p))=1.08(0.8p)=0.864pf(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.

Composition Tasks at a Glance

Composition shows up in a wide range of tasks — evaluating at a point, finding a formula, determining a domain, decomposing a complex expression, verifying inverses. The procedures share the same inside-out evaluation logic but the deliverable differs from task to task. The table below collects every task covered above with what's given, the procedure to follow, and an example of the result — useful as a checklist when a problem invokes composition and the right approach isn't immediately obvious.
Task Given Procedure Example result
Evaluate at a point f, g, input a compute g(a), then apply f to the result (f ∘ g)(4) = 101
Find composite formula formulas for f and g substitute g(x) into f wherever f's input appears; simplify 4x² + 4x − 3
Find domain f, g and their domains require x in dom(g) AND g(x) in dom(f); intersect [3, ∞)
Test commutativity f and g compute both f ∘ g and g ∘ f; compare formulas x² + 5 ≠ x² + 10x + 25
Chain three or more f, g, h, … evaluate innermost first, then work outward (f ∘ g ∘ h)(3) = 49
Compose with itself a single f substitute f(x) into f wherever its input appears f(x) = 2x ⇒ f(f(x)) = 4x
Decompose a single h(x) identify the outer operation; what it acts on is the inner √(x² + 1) = √x ∘ (x² + 1)
Verify inverses f and candidate f⁻¹ check that both f(f⁻¹(x)) and f⁻¹(f(x)) reduce to x both compositions = x ⇒ confirmed

Function Composition FAQ

Which function is applied first in f(g(x))?

+
The inner one. Work outward from the input: g acts on x first, and f then acts on whatever g produced. The notation reads right to left, which feels backwards compared with the written order and is the single most common source of composition mistakes.Read more →

Is f(g(x)) the same as g(f(x))?

+
Almost never. Composition is not commutative, so reversing the order generally produces a completely different function. Squaring then adding three gives a different result from adding three then squaring. The two coincide only in special cases, most notably when the functions are inverses of each other.Read more →

How do you find the domain of a composite function?

+
Two conditions apply at once. The input must be in the domain of the inner function, and the value the inner function produces must be in the domain of the outer one. Simplifying the composite first can hide the second restriction, so the domain must be worked out before simplifying.Read more →

How do you decompose a function into a composition?

+
Look for a self-contained expression appearing inside another operation, and call that the inner function. Whatever is done to it becomes the outer one. For a root of a quadratic, the quadratic is inner and the root is outer. Decompositions are not unique, so several correct answers exist.Read more →

What happens when you compose a function with its inverse?

+
You get the input back unchanged, in either order. That is precisely what being an inverse means: one function undoes what the other did. This property is what makes composition the standard way to verify a candidate inverse, and it holds only across the domains where both are defined.Read more →