Composite Function Calculator
Enter f(x) and g(x) and get (f ∘ g)(x) and (g ∘ f)(x) expanded step by step, with values at any x you choose. Free, no signup.
A composite function is one function fed into another: (f ∘ g)(x) means “work out g(x) first, then feed that answer into f”. Type both functions above and this calculator builds both compositions for you: (f ∘ g)(x) and (g ∘ f)(x), which are usually different. Polynomials are expanded and simplified in full; functions like square roots, sines and exponentials are returned in clean substituted form. Add an x value and it also evaluates both compositions there, working inside-out so you can check each stage.
How to use this calculator
- Enter f(x), the outer function for (f ∘ g)(x). Example: x^2 + 1.
- Enter g(x), the inner function. Example: 2x – 3.
- Optionally enter an x value to evaluate both compositions at that point.
- Press Calculate. You get (f ∘ g)(x) and (g ∘ f)(x) with the substitution shown step by step, plus a practice problem and a graph link for polynomial results.
You can use +, -, *, /, powers with ^, and functions such as sqrt(x), sin(x), cos(x), exp(x) and ln(x). Multiplication can be implied: 2x and 2(x + 1) both work.
The formula: (f ∘ g)(x) = f(g(x))
Composition is substitution. To find (f ∘ g)(x), take the formula for f and replace every x in it with the whole formula for g, in parentheses:
(f ∘ g)(x) = f(g(x))
The parentheses matter. If f(x) = x^2 + 1 and g(x) = 2x – 3, then (f ∘ g)(x) = (2x – 3)^2 + 1, not 2x^2 – 3. Squaring the whole of g first, then adding 1, gives 4x^2 – 12x + 10. Swapping the order gives a different function: (g ∘ f)(x) = 2(x^2 + 1) – 3 = 2x^2 – 1.
Worked example
Let f(x) = x^2 + 1 and g(x) = 2x – 3.
(f ∘ g)(x): substitute g into f: (2x – 3)^2 + 1 = 4x^2 – 12x + 9 + 1 = 4x^2 – 12x + 10. At x = 2, work inside-out: g(2) = 1, then f(1) = 1 + 1 = 2. The expanded form agrees: 4(4) – 12(2) + 10 = 2.
(g ∘ f)(x): substitute f into g: 2(x^2 + 1) – 3 = 2x^2 – 1. At x = 2: f(2) = 5, then g(5) = 10 – 3 = 7.
When are composite functions used?
Anywhere one process feeds into another. A shop discount followed by tax is a composition: the tax function is applied to the discounted price, not the original. Unit conversions chain the same way (hours to minutes, then minutes to seconds). In calculus, the chain rule exists precisely because real functions are compositions: the derivative of (2x – 3)^2 treats the square as the outer function and 2x – 3 as the inner one, which is why this calculator pairs naturally with the Derivative Calculator.
Frequently asked questions
A composite function is formed by feeding the output of one function into another. (f ∘ g)(x) = f(g(x)): g runs first, and its result becomes the input to f. The small circle is read as “of”, so (f ∘ g)(x) is “f of g of x”.
Usually not. With f(x) = x^2 + 1 and g(x) = 2x – 3, (f ∘ g)(x) = 4x^2 – 12x + 10 but (g ∘ f)(x) = 2x^2 – 1. The order only stops mattering for special pairs, such as a function composed with its own inverse.
Work inside-out. For (f ∘ g)(2), first find g(2), then put that result into f. Never expand the whole composition just to get one value: the inside-out route is shorter and less error-prone. This calculator shows both stages.
Polynomials (x^2 + 1, 2x – 3), roots (sqrt(x)), trig (sin(x), cos(x), tan(x)), exponentials (exp(x) or e^x), logs (ln(x), log(x)) and fractions (1/x). If the composition is a polynomial it is expanded fully; anything else is returned in substituted form, which is the exact answer.
Because at that x, the inner result lands outside the outer function’s domain: for example g(x) = -1 fed into f(x) = sqrt(x), or g(x) = 0 fed into f(x) = 1/x. The composition genuinely has no real value there, so the calculator says so instead of inventing one. The formulas for (f ∘ g)(x) and (g ∘ f)(x) are still shown.