Precalculus Intermediate

Function Composition Calculator

Compute (f∘g)(x), (g∘f)(x), (f∘f)(x), and (g∘g)(x) with full substitution steps. Evaluate at a specific x-value and explore domain restrictions — see exactly why order matters.

Live Calculator · Step-by-Step · Precalculus
Function Inputs
Active Composition
(f∘g)(x) = f(g(x)) — substitute g(x) into f
Evaluate at x = __ (optional)
Examples
Use ^ for powers, sqrt() for radicals, abs() for absolute value, * for multiplication. Coefficients like 2x are recognized automatically.
Results
Enter f(x) and g(x) above and press Compute All Compositions to see all four results.
(f∘g)(x)
(g∘f)(x)
(f∘f)(x)
(g∘g)(x)
Result
Domain of Selected Composition
Step-by-Step Substitution
Composition Is NOT Commutative
(f∘g)(x) = f(g(x))  ≠  g(f(x)) = (g∘f)(x)   in general

What "apply g first, then f" means: In (f∘g)(x) you input x into g to get g(x), then feed that output as the input to f. The final result is f(g(x)).

Why order matters: Try f(x) = x² and g(x) = x + 1. Then (f∘g)(x) = (x+1)² = x²+2x+1, but (g∘f)(x) = x²+1 — completely different polynomials.

When they are equal: (f∘g) = (g∘f) only in special cases, notably when f and g are inverses of each other — because then each undoes the other.

  • Always write g(x) in parentheses before substituting into f.
  • Expand powers carefully: (ax + b)² = a²x² + 2abx + b².
  • Check the domain after composing — it can be more restricted than either function alone.
  • Use the Evaluate field to verify your answer at a specific x numerically.
Domain Restrictions in Compositions
Dom(f∘g) = { x ∈ Dom(g) : g(x) ∈ Dom(f) }

Two-step check: x must (1) be in the domain of g so that g(x) is defined, and (2) g(x) must land inside the domain of f so that f can accept it. Both conditions must hold simultaneously.

Example — radical: If f(x) = √x and g(x) = x − 4, then (f∘g)(x) = √(x−4) requires x − 4 ≥ 0, so the domain of f∘g is x ≥ 4, even though both f and g alone have different domains.

Example — rational: If f(x) = 1/x and g(x) = x + 1, then (f∘g)(x) = 1/(x+1) excludes x = −1, even though g(x) is defined everywhere.

  • For √(g(x)): solve g(x) ≥ 0 for the domain.
  • For 1/(g(x)): solve g(x) = 0 and exclude those x values.
  • For |g(x)|: no extra restriction — absolute value is defined for all real x.
  • For polynomials composed: domain is all real numbers (ℝ).

Struggling with function composition?

One-on-one Precalculus tutoring walks through substitution, domain analysis, and inverse verification on your exact homework — building the fluency that makes compositions feel automatic.

Book a Free Consultation →