Function Composition Calculator: Find f(g(x)), g(f(x)) and the Domain

Enter f(x) and g(x) and the solver builds f(g(x)) and g(f(x)), simplifies them, evaluates at any number and works out the domain of each composite, which is where most mistakes happen.

Compose Any Two Functions With the Mathvelo Solver

⚡ Instant🧠 AI explains📷 Scan

What Function Composition Means

Composition feeds the output of one function into another. The notation (f ∘ g)(x) = f(g(x)) reads from the inside out: do g first, then f. Think of a two-step machine where g is the first station and f the second.

Find f(g(x)) and g(f(x)) for f(x) = 2x + 3 and g(x) = x²Try it in the solver ↑

f(x) = 2x + 3, g(x) = x²

  1. For f(g(x)), replace the x in f with g(x) = x².
  2. f(g(x)) = 2(x²) + 3 = 2x² + 3.
  3. For g(f(x)), replace the x in g with f(x) = 2x + 3.
  4. g(f(x)) = (2x + 3)² = 4x² + 12x + 9.
  5. They differ, so the order matters.

Answer: f(g(x)) = 2x² + 3 and g(f(x)) = 4x² + 12x + 9

Evaluating a Composition at a Number

Find f(g(2)) and g(f(2)) for the same f and gTry it in the solver ↑

f(g(2)) and g(f(2))

  1. Work inside out. g(2) = 2² = 4.
  2. Then f(4) = 2(4) + 3 = 11, so f(g(2)) = 11.
  3. For the other order, f(2) = 2(2) + 3 = 7.
  4. Then g(7) = 7² = 49, so g(f(2)) = 49.
  5. Check against the formulas: 2(2)² + 3 = 11 and (2·2 + 3)² = 49 ✓

Answer: f(g(2)) = 11 and g(f(2)) = 49

Numbers are the easiest way to catch an algebra slip. If your formula and the step-by-step number disagree, the formula is wrong.

The Domain of a Composite Function

The domain of f(g(x)) is every x that is allowed in g and whose output g(x) is allowed in f. Square roots and denominators are where this bites.

Find the domain of f(g(x)) for f(x) = √x and g(x) = x − 4Try it in the solver ↑

f(x) = √x, g(x) = x − 4

  1. g(x) = x − 4 accepts every real x.
  2. f(g(x)) = √(x − 4).
  3. The square root needs x − 4 ≥ 0.
  4. So x ≥ 4.
  5. Compare with g(f(x)) = √x − 4, whose domain is x ≥ 0. Two different composites, two different domains.

Answer: Domain of f(g(x)): [4, ∞)

Decomposing a Function Into Two Parts

Going the other way is a skill in calculus, where the chain rule needs it. Spot the inner function, the thing in brackets or under a root, and call the rest the outer function.

h(x)Inner g(x)Outer f(x)
(3x + 1)⁵3x + 1x⁵
√(x² + 9)x² + 9√x
e^(2x)2xeˣ
1/(x − 4)x − 41/x

Order Matters: A Numbers Check

Let f(x) = x + 1 and g(x) = 2x. Then f(g(3)) = f(6) = 7, but g(f(3)) = g(4) = 8. In general (f∘g)(x) = 2x + 1 and (g∘f)(x) = 2x + 2. Composition is not commutative, so always read it from the inside out.

Our Take: What Is Overrated, Underrated and Plain Wrong

Overrated: the notation. (f∘g)(x) just means “apply g, then f”.

Underrated: substituting the whole expression in brackets. Writing f(g(x)) with g(x) in brackets prevents most sign errors.

Plain wrong: treating f(g(x)) as f(x) × g(x). That is a product, not a composition.

Composition in Everyday Life

A 20% discount followed by 8% sales tax is two functions composed. With g(p) = 0.8p and f(p) = 1.08p, f(g(p)) = 1.08 × 0.8p = 0.864p. On a $100 item that is $86.40 whichever order you apply them, but only because multiplication commutes. Add a flat $5 coupon in the mix and the order suddenly matters.

  • Reading f(g(x)) from the left: do g first.
  • Multiplying f(x) · g(x) instead of composing.
  • Forgetting the domain restriction of the inner function.

Why Students Get Stuck on Function Composition, and What a Good Calculator Should Do

Searching for help with function composition usually starts late at night with one problem that will not work out. F(g(x)) reads inside-out, and the domain of the result is easy to overlook. A good calculator fixes that by showing each step, checking its own answer and explaining the idea in plain words. This section covers what students struggle with, what they want, and how this page responds.

In short: students need to substitute in the right order and keep the domain in view, not just see a final number, and a calculator earns trust only when its steps can be checked.

Understand the pain points

What students get stuck on

Most mistakes here are not about arithmetic. They come from one rule applied the wrong way round, which is why seeing every step matters.

Understand the frustrations and desires

What they feel, and what they want

Each frustration points to a wish: a clearer step, a built-in check, an explanation in plain words.

  • Wants the substitution shown in order
  • Wants f(g(x)) and g(f(x)) side by side
  • Wants the domain of the composite

Build the page around their intent

Each intent has a place on this page

The page follows intent, not features, so each need has a clear starting point.

  • I need an answer now: type the problem into the calculator at the top of this page.f(x) = 2x + 1 and g(x) = x^2, find f(g(x))
  • I need to understand: the sections below explain the idea in plain words and list the common mistakes.
  • I need to check my work: every step is shown, so the first line that differs from yours is the one to study.
  • I need practice: open the solver, tap + and choose Create Practice Test.
  • I need it explained aloud: in the solver, tap + and choose Create Video.

Function Composition: Questions People Ask

What is function composition?

Applying one function to the output of another. (f ∘ g)(x) = f(g(x)).

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

Usually not. Order matters, as the 2x + 3 and x² example shows.

How do I find the domain of a composite?

Take the domain of the inner function, then remove any x where its output is not allowed in the outer function.

What is the difference between f ∘ g and f · g?

f ∘ g means f(g(x)), a substitution. f · g means f(x) multiplied by g(x).

Where is composition used?

In the chain rule, in unit conversions, in pricing and in any step-by-step pipeline.

How do I decompose a function?

Identify what is done first to x, call it g, and treat the remaining operation as f.

How do I find f(g(x))?

Replace every x in f with the whole expression g(x), then simplify. If f(x) = x² and g(x) = x + 3, f(g(x)) = (x + 3)².

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

Usually not. Composition depends on order, as the example above shows.

How do I find the domain of a composite function?

The input must be in the domain of g, and g(x) must be in the domain of f. Check both conditions.

What does (f∘g)(x) mean?

It means f(g(x)): apply g first, then f.

↑