Mathwords logoMathwords

Composition

Composition

Combining two functions by substituting one function's formula in place of each x in the other function's formula. The composition of functions f and g is written f ° g, and is read aloud "f composed with g." The formula for f ° g is written (f ° g)(x). This is read aloud "f composed with g of x."

Note: Composition is not commutative. That is, (f ° g)(x) is usually different from (g ° f)(x). The example below illustrates this.

 

Example:    f(x) = 3x2 + 12x – 1  and  g(x) = 4x + 1

 

  1(f ° g)(x) = 3(4x + 1)2 + 12(4x + 1) – 1
   

= 3(16x2 + 8x + 1) + 48x + 12 – 1
= 48x2 + 72x + 14

 

  1(g ° f)(x) = 4(3x2 + 12x – 1) + 1
    = 12x2 + 48x – 4 + 1
= 12x2 + 48x – 3

 

See also

Identity of an operation, identity function, inverse, composite

Key Formula

(fg)(x)=f(g(x))(f \circ g)(x) = f\bigl(g(x)\bigr)
Where:
  • ff = The outer function, applied second
  • gg = The inner function, applied first
  • xx = The input value
  • g(x)g(x) = The output of g, which becomes the input to f

Worked Example

Problem: Let f(x)=2x+3f(x) = 2x + 3 and g(x)=x2g(x) = x^2. Find (fg)(x)(f \circ g)(x) and evaluate it at x=4x = 4.
Step 1: Write the composition definition. (fg)(x)(f \circ g)(x) means apply gg first, then ff.
(fg)(x)=f(g(x))(f \circ g)(x) = f\bigl(g(x)\bigr)
Step 2: Substitute g(x)=x2g(x) = x^2 into ff. Everywhere ff has its input variable, replace it with x2x^2.
f(x2)=2(x2)+3=2x2+3f\bigl(x^2\bigr) = 2(x^2) + 3 = 2x^2 + 3
Step 3: So the composed function is:
(fg)(x)=2x2+3(f \circ g)(x) = 2x^2 + 3
Step 4: Evaluate at x=4x = 4 by substituting into the result.
(fg)(4)=2(4)2+3=2(16)+3=32+3=35(f \circ g)(4) = 2(4)^2 + 3 = 2(16) + 3 = 32 + 3 = 35
Answer: (fg)(x)=2x2+3(f \circ g)(x) = 2x^2 + 3, and (fg)(4)=35(f \circ g)(4) = 35.

Another Example

This example reverses the order of composition to demonstrate that fgf \circ g and gfg \circ f generally produce different results — a key property students must understand.

Problem: Using the same functions f(x)=2x+3f(x) = 2x + 3 and g(x)=x2g(x) = x^2, find (gf)(x)(g \circ f)(x) and evaluate it at x=4x = 4. Compare to the first example to see that composition is not commutative.
Step 1: Write the composition in the reversed order. (gf)(x)(g \circ f)(x) means apply ff first, then gg.
(gf)(x)=g(f(x))(g \circ f)(x) = g\bigl(f(x)\bigr)
Step 2: Substitute f(x)=2x+3f(x) = 2x + 3 into gg. Since gg squares its input, square the entire expression (2x+3)(2x + 3).
g(2x+3)=(2x+3)2g(2x + 3) = (2x + 3)^2
Step 3: Expand the squared binomial.
(2x+3)2=4x2+12x+9(2x + 3)^2 = 4x^2 + 12x + 9
Step 4: Evaluate at x=4x = 4.
(gf)(4)=4(16)+12(4)+9=64+48+9=121(g \circ f)(4) = 4(16) + 12(4) + 9 = 64 + 48 + 9 = 121
Step 5: Compare: (fg)(4)=35(f \circ g)(4) = 35 but (gf)(4)=121(g \circ f)(4) = 121. The order matters.
(fg)(4)(gf)(4)(f \circ g)(4) \neq (g \circ f)(4)
Answer: (gf)(x)=4x2+12x+9(g \circ f)(x) = 4x^2 + 12x + 9, and (gf)(4)=121(g \circ f)(4) = 121. This differs from (fg)(4)=35(f \circ g)(4) = 35, confirming composition is not commutative.

Frequently Asked Questions

What is the difference between composition and multiplication of functions?
Multiplication of functions means (fg)(x)=f(x)×g(x)(f \cdot g)(x) = f(x) \times g(x) — you evaluate both functions at xx and multiply the outputs. Composition means (fg)(x)=f(g(x))(f \circ g)(x) = f(g(x)) — you feed the output of gg into ff as its input. These are fundamentally different operations and almost always give different results.
Does the order of composition matter?
Yes. Composition is not commutative, meaning (fg)(x)(f \circ g)(x) is generally not equal to (gf)(x)(g \circ f)(x). In fgf \circ g, you apply gg first and then ff. Reversing the order changes which function processes the input and which processes the intermediate result. Always pay close attention to which function is the outer function and which is the inner function.
How do you find the domain of a composition?
The domain of (fg)(x)(f \circ g)(x) consists of all xx-values in the domain of gg for which g(x)g(x) is also in the domain of ff. First, xx must be a valid input for gg. Second, the output g(x)g(x) must be a valid input for ff. You need to check both conditions.

Composition $(f \circ g)(x)$ vs. Multiplication $(f \cdot g)(x)$

Composition $(f \circ g)(x)$Multiplication $(f \cdot g)(x)$
DefinitionOutput of g becomes input of f: f(g(x))f(g(x))Multiply the two outputs: f(x)g(x)f(x) \cdot g(x)
Notation(fg)(x)(f \circ g)(x) with a small circle(fg)(x)(f \cdot g)(x) or f(x)g(x)f(x)g(x)
Commutative?No — order usually mattersYes — multiplication is commutative
Example with f(x)=2xf(x)=2x, g(x)=x+1g(x)=x+1f(g(x))=2(x+1)=2x+2f(g(x)) = 2(x+1) = 2x+2f(x)g(x)=2x(x+1)=2x2+2xf(x) \cdot g(x) = 2x(x+1) = 2x^2+2x

Why It Matters

Composition appears throughout algebra, precalculus, and calculus. The chain rule in calculus — one of the most important differentiation rules — is built entirely on recognizing a function as a composition. You also use composition to verify that two functions are inverses: if (fg)(x)=x(f \circ g)(x) = x and (gf)(x)=x(g \circ f)(x) = x, then ff and gg are inverse functions.

Common Mistakes

Mistake: Applying the functions in the wrong order. Students see (fg)(x)(f \circ g)(x) and apply ff first because ff appears first when reading left to right.
Correction: Remember that (fg)(x)=f(g(x))(f \circ g)(x) = f(g(x)). The inner function gg acts on xx first, and then ff acts on the result. Work from the inside out: start with g(x)g(x), then plug that into ff.
Mistake: Confusing composition with multiplication. Students interpret fgf \circ g as f(x)×g(x)f(x) \times g(x).
Correction: The circle symbol \circ means composition, not multiplication. Composition feeds one function's output into the other; multiplication computes both outputs separately and multiplies them. These give different results.

Related Terms

  • FunctionComposition combines two functions into one
  • FormulaSubstitution of formulas performs composition
  • CommutativeComposition is not commutative
  • Identity FunctionComposing with the identity returns the original function
  • InverseInverse functions undo each other under composition
  • Identity of an OperationThe identity function is the identity element for composition
  • CompositeThe result of a composition is a composite function