Skip to content
  • Open the math solver
  • Ask the AI tutor
  • Find an AP course
  • Create a quiz
  • Open the calculator
  • Graphing Calculator
  • Browse all calculators
  • Read math guides
↑ ↓Enter to open · Esc to close
Solve a problem

Function Composition Calculator

Enter f(x) and g(x) to build f∘g, g∘f, f∘f or g∘g, simplify it, evaluate it at any point and see the domain of the composite function.

Examples

About the Function Composition Calculator

Composition chains two functions so that the output of one becomes the input of the other. It is how complicated formulas are built from simple ones: x−4\sqrt{x - 4} is a square root applied after subtracting 4, and (2x−3)2+1(2x - 3)^2 + 1 is squaring and adding one applied after a linear map. Recognising these layers is essential for the chain rule, for inverse functions and for modelling processes that happen in stages.

This calculator substitutes one function into another, expands and simplifies the result, and works out the domain of the composite, including the restrictions inherited from the inner function. If you supply a value it also evaluates the composition there from the inside out, so you can see how the number moves through each function in turn.

What is function composition?

The composition of ff with gg, written (f∘g)(x)(f \circ g)(x), is defined as f(g(x))f(g(x)): first apply gg, then apply ff to the result. The function written on the right acts first, which is the reverse of the reading order.

Composition is not commutative. For f(x)=x2f(x) = x^2 and g(x)=x+1g(x) = x + 1, f(g(x))=(x+1)2f(g(x)) = (x + 1)^2 while g(f(x))=x2+1g(f(x)) = x^2 + 1. A function can also be composed with itself: f∘ff \circ f applies ff twice.

How to use the Function Composition Calculator

  1. Enter the outer function f(x) and the second function g(x), both in terms of xx.
  2. Choose the composition: f∘g, g∘f, f∘f or g∘g.
  3. Optionally enter a value of xx to evaluate the composite at that point.
  4. Press Compose to see the substitution, the simplified result and its domain.
  5. Compare with the reverse order to see how the result changes.

Formulas

Definition

(f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x))

Domain of a composition

Dom⁡(f∘g)={x∈Dom⁡(g):g(x)∈Dom⁡(f)}\operatorname{Dom}(f \circ g) = \{x \in \operatorname{Dom}(g) : g(x) \in \operatorname{Dom}(f)\}

Associativity

f∘(g∘h)=(f∘g)∘hf \circ (g \circ h) = (f \circ g) \circ h

Inverse check

f(f−1(x))=xf(f^{-1}(x)) = x

Worked example: f(g(x)), f = x² + 1, g = 2x − 3, at x = 2

The example uses f(x)=x2+1f(x) = x^2 + 1 and g(x)=2x−3g(x) = 2x - 3 and builds f∘gf \circ g. Every xx in ff is replaced by the whole expression 2x−32x - 3, giving (2x−3)2+1(2x - 3)^2 + 1, which expands to 4x2−12x+104x^2 - 12x + 10.

The example also evaluates at x=2x = 2. In stages, g(2)=1g(2) = 1 and f(1)=2f(1) = 2; the simplified formula gives 16−24+10=216 - 24 + 10 = 2, the same value. Both functions are polynomials, so the domain is all real numbers.

The solution below is generated by the same engine that powers the calculator above.

Final answer

(f∘g)(x)=4x2−12x+10(f \circ g)(x) = 4{x}^{2}-12x+10

How we read your problem

Find (f ∘ g)(x) = f(g(x)) and evaluate it.

f(x)=x2+1, g(x)=2x−3f(x) = {x}^{2}+1,\ g(x) = 2x-3

Step-by-step solution

  1. Write the functions

    f(x)=x2+1,g(x)=2x−3f(x) = {x}^{2}+1,\quad g(x) = 2x-3
  2. (f ∘ g)(x) means f(g(x)): put g(x) in place of every x in f

    (f∘g)(x)=f(2x−3)(f \circ g)(x) = f\big(2x-3\big)
  3. Substitute

    (f∘g)(x)=(2x−3)2+1(f \circ g)(x) = {\left(2x-3\right)}^{2}+1
  4. Expand and collect like terms

    (f∘g)(x)=4x2−12x+10(f \circ g)(x) = 4{x}^{2}-12x+10
  5. Domain: x must be allowed in g, and g(x) must be allowed in f

    Domain of f∘g: (−∞,∞)\text{Domain of } f \circ g:\ (-\infty, \infty)
  6. Evaluate inside-out at x = 2: first g(2) = 1

    g(2)=1g(2) = 1
  7. Then f(1) = 2

    f(1)=2f\big(1\big) = 2

Formulas used

  • Composition

    (f∘g)(x)=f(g(x))(f \circ g)(x) = f\big(g(x)\big)

Composition feeds the output of g into f. The order matters: f∘g applies g first and is usually different from g∘f. The domain is worked out before simplifying, since cancelling factors can hide values the composite cannot accept.

Verification

  • Checked: f(g(x)) and the final formula agree at sample points.
  • Checked: the simplified formula also gives 2 at x = 2.

Detailed explanation

Substituting correctly

The safest way to compose is to rewrite the outer function with empty brackets in place of xx, such as f(  )=(  )2+1f(\;) = (\;)^2 + 1, and then place the entire inner expression inside every bracket. The brackets matter: replacing xx in x2x^2 with 2x−32x - 3 gives (2x−3)2(2x - 3)^2, not 2x−322x - 3^2.

Once substituted, the result is expanded and like terms are collected. The calculator shows the unsimplified substitution first so you can compare it with your own working, then the simplified form.

Finding the domain

An input belongs to the domain of f∘gf \circ g only if gg accepts it and ff accepts what gg produces. For f(x)=xf(x) = \sqrt{x} and g(x)=x−4g(x) = x - 4, gg accepts every number, but ff needs a non-negative input, so x−4≥0x - 4 \geq 0 and the domain is [4,∞)[4, \infty).

Restrictions from the inner function survive even when simplification hides them. With f(x)=x2f(x) = x^2 and g(x)=xg(x) = \sqrt{x}, the composite simplifies to xx, yet only x≥0x \geq 0 is allowed because gg must be defined first. That is why the domain is computed from both stages, not just from the final formula.

Where composition is used

The chain rule in calculus differentiates a composition: ddxf(g(x))=f′(g(x)) g′(x)\frac{d}{dx} f(g(x)) = f'(g(x))\,g'(x). Spotting the inner and outer functions is the first step in using it. Composition also describes changes of units, repeated percentage changes and transformations of graphs: f(x−2)f(x - 2) is ff composed with a shift of two to the right.

Decomposition is the reverse skill: given h(x)=3x+7h(x) = \sqrt{3x + 7}, choose an inner function g(x)=3x+7g(x) = 3x + 7 and an outer function f(x)=xf(x) = \sqrt{x} so that h=f∘gh = f \circ g. There is usually more than one valid choice, and the best one is the split that makes the next step, such as differentiating or inverting, easiest. Practising with the calculator in both directions builds the habit of seeing functions as layers.

Common mistakes

  • Applying the functions in the wrong order; in f(g(x))f(g(x)) the inner function gg acts first.
  • Multiplying the functions instead of composing them: f(g(x))f(g(x)) is not f(x) g(x)f(x)\,g(x).
  • Dropping brackets when substituting, which changes powers and signs.
  • Taking the domain only from the simplified formula and losing restrictions from the inner function.
  • Assuming f∘g=g∘ff \circ g = g \circ f; check both orders.

Tips

  • Evaluate at a simple number in stages to check a simplified composite.
  • Write the outer function with empty brackets before substituting.
  • List the domain conditions of the inner function first, then those of the outer one.
  • Use the inverse function calculator, then compose to confirm f(f−1(x))=xf(f^{-1}(x)) = x.
  • Name the inner and outer functions before differentiating with the chain rule.

Frequently asked questions

What does f(g(x)) mean?

It means apply g to x first, then apply f to the result. The composite is written f∘g, and the function on the right always acts first.

Is f∘g the same as g∘f?

Usually not. For f(x) = x² and g(x) = x + 1, f(g(x)) = (x + 1)² but g(f(x)) = x² + 1. The calculator lets you compute both orders.

How do you find the domain of a composite function?

Take the inputs allowed by the inner function, then keep only those whose outputs are allowed by the outer function. Restrictions from the inner function remain even if the simplified formula hides them.

Can I compose a function with itself?

Yes. Choose f∘f or g∘g. For f(x) = 2x + 1, f(f(x)) = 4x + 3, so f(f(3)) = 15.

How is composition related to the chain rule?

The chain rule differentiates a composition: the derivative of f(g(x)) is f′(g(x)) times g′(x). Identifying the inner and outer functions is the first step.

Does the calculator evaluate the composite at a point?

Yes. Enter a value of x and it evaluates inside-out: first the inner function at that value, then the outer function at the result. Substituting the same value into the simplified formula should give the same number.

How do I check that two functions are inverses?

Compose them in both orders. If f(g(x)) and g(f(x)) both simplify to x on the relevant domains, the functions are inverses of each other.

Compose your functions

Enter f(x) and g(x) above to see the composite simplified, evaluated and with its domain.

More math calculators