Math Solver Free

Function Composition Calculator

(f∘g)(x) and (g∘f)(x), expanded — instantly and free.

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

  1. f(x) = field: type the outer function here, using x as the variable — for example, 2x + 1.
  2. 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.
  3. Press Compose Functions: the calculator substitutes each function into the other and simplifies both results.
  4. 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.

Frequently Asked Questions

What is function composition?

Function composition feeds one function's output into another function as its input. The notation (f∘g)(x) means compute g(x) first, then apply f to that result. It models any two-stage process — converting a measurement and then rounding it, for instance — as a single new function built from the two original ones.

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

Almost never — the order of composition matters, because a different function runs first. If f doubles its input and g squares its input, then (f∘g)(3) means square first, then double: 9 becomes 18. But (g∘f)(3) means double first, then square: 6 becomes 36. The two compositions agree only in special cases, so always check which function the notation places on the inside.

How do you evaluate a composition?

Work from the inside out. To evaluate (f∘g)(x) as a formula, substitute the entire expression for g(x) everywhere x appears in f, then expand and simplify. To evaluate at a number, it is often quicker to compute the inner value first — find g(3), say — and then apply f to that single number. The tool above performs the substitution and simplification automatically and shows the steps.

Is this calculator free?

Yes — composing functions here is completely free, with no sign-up and nothing to install. Enter f and g in the two fields, press the button, and both composed functions plus the step-by-step substitutions appear right on this page, computed in your browser. You can rerun it with different functions as often as you like.

What is the domain of a composite function?

The domain of (f∘g) contains only the inputs that survive both stages: x must be in the domain of g, and the value g(x) must be in the domain of f. For example, if g(x) = x − 4 and f(x) = √x, then (f∘g)(x) = √(x − 4), which requires x − 4 ≥ 0, so the domain is x ≥ 4, although g by itself accepts every real number.

Can a function be composed with itself?

Yes. (f∘f)(x) means applying f twice in a row: if f(x) = 2x + 1, then (f∘f)(x) = 2(2x + 1) + 1 = 4x + 3. Repeating a composition like this is called iteration, and it underlies compound interest, where a growth function is applied year after year, as well as repeated transformations in graphics. To try it, enter the same expression in both fields above.

Related Tools & Guides

About the MathSolverFree Team

The MathSolverFree Team builds and maintains the calculators and step-by-step solvers on this site. Every tool is checked against worked textbook examples before it is published, and the method behind each solver is written out in full — in the worked examples on the page and in our guides — so you can see exactly how an answer is reached, not just the answer itself.

How we build and test our tools·More about the team