How Function Composition Works
Function composition is how mathematics models any process that happens in stages. One function's output becomes the next function's input: g transforms x first, and f then transforms whatever g produced. This calculator takes any two functions f(x) and g(x), builds both possible compositions for you — (f∘g)(x) and (g∘f)(x) — expands and simplifies each one, and shows the substitution steps, so you can see exactly where every term came from instead of receiving a bare answer to copy. It is built for algebra and precalculus students checking homework, and for anyone who needs a composite formula they can genuinely trust.
Reading the Notation (f∘g)(x), Symbol by Symbol
The symbol ∘ is the composition operator — it is not a multiplication sign and not the letter o. The expression (f∘g)(x) is defined precisely as f(g(x)): the function written on the right of the circle, g, is applied first, and the function on the left, f, is applied to g's result. Within that definition, x is the original input, g(x) is the intermediate value after the first stage, f is called the outer function, and g is the inner function. The notation is read “f of g of x”, and when you evaluate at a number — say (f∘g)(3) — you always compute g(3) first and then apply f to that single number.
How to Use This Calculator
- f(x) = field: type the outer function here, using x as the variable — for example, 2x + 1.
- g(x) = field: type the inner function here, such as x^2 — or tap one of the preset example chips to load a ready-made pair instantly.
- Press Compose Functions: the calculator substitutes each function into the other and simplifies both results.
- Read the two outputs side by side — (f∘g)(x) = f(g(x)) and (g∘f)(x) = g(f(x)) — followed by numbered steps showing the substitution that produced each one, so the two orders are easy to compare.
Worked Example 1: Evaluating (f∘g)(3)
Take f(x) = 2x + 1 and g(x) = x². There are two routes to (f∘g)(3), and they must agree. Route one works numerically from the inside out: evaluate the inner function first, g(3) = 3² = 9, then feed that result into f: f(9) = 2(9) + 1 = 19. Route two builds the composite formula first: (f∘g)(x) replaces every x in f with x², giving 2x² + 1, and only then substitutes the number: 2(3²) + 1 = 2(9) + 1 = 19. Both routes land on 19, which is exactly the cross-check you should run on your own work. Notice what did not happen anywhere in this working: the functions were never multiplied together. Composition is substitution, not multiplication — multiplying would have produced the entirely different expression (2x + 1)(x²) = 2x³ + x².
Worked Example 2: Both Orders, With a Binomial Square
Now take f(x) = 3x − 2 and g(x) = x² + 1. For (f∘g)(x), substitute x² + 1 into f: 3(x² + 1) − 2 = 3x² + 3 − 2 = 3x² + 1. For (g∘f)(x), substitute 3x − 2 into g: (3x − 2)² + 1, and expand the square carefully — (3x − 2)² = 9x² − 12x + 4, cross term included — giving 9x² − 12x + 5. Verify both at x = 2. Inner first for (f∘g): g(2) = 5, then f(5) = 13, and the formula agrees: 3(2²) + 1 = 13. Inner first for (g∘f): f(2) = 4, then g(4) = 17, and again the formula agrees: 9(4) − 12(2) + 5 = 36 − 24 + 5 = 17. Two different formulas, two different values — order is everything.
Watch the Domain
A composition is only defined where both steps work: x must be in g’s domain, and g(x) must be in f’s domain. If g(x) = √x and f(x) = 1/x, then (f∘g)(x) = 1/√x fails at x = 0 even though each function is fine elsewhere — g(0) = 0 lands outside f’s domain. When the calculator returns an expression, check those two checkpoints before trusting it.
When Composition Shows Up in Real Life
Chained unit conversions are compositions: converting Kelvin to Celsius and then Celsius to Fahrenheit applies two functions in sequence. Pricing pipelines compose too — a shop that discounts an item and then adds sales tax is applying a tax function to a discount function's output, and swapping the order changes the final price. Programmers compose constantly, piping data through a cleaning function, then a sorting function, then a formatting function. And in the classroom, composition is the standard test for inverse functions: f and g are inverses exactly when both compositions collapse to plain x.
Three Mistakes Students Make With Composition
First, multiplying instead of substituting: (f∘g)(x) is f(g(x)), never f(x) × g(x). Second, reversing the order: the function nearest x acts first, so in (f∘g)(x) it is g that runs first even though f is written first — reading the notation left to right as an instruction sequence is the single most common source of wrong answers. Third, expanding a squared binomial term by term: (3x − 2)² is not 9x² + 4; the cross term −12x is real, and dropping it corrupts everything that follows.
Composition is how inverses are verified: try our inverse function calculator or simplify the substituted expressions with the algebra calculator.