ΣCalcSolver
Algebra

Function Composition Calculator

Type two functions and choose which composition you need. The solver puts the inner function into the outer one, shows the result before and after simplifying, and can work out the value at a number you choose, one function at a time.

f(x) = x ^ 2 + 1
g(x) = 2 x - 3
Inside: g, outside: f
f(g(x)) = (f ∘ g)(x)
Replace every x in f(x) with g(x) = 2 x - 3:
f(g(x)) = (2 x - 3) ^ 2 + 1
Expand and simplify:
f(g(x)) = 4 * x ^ 2 - 12 * x + 10
Domain: x must be allowed in the inner function, and its output must be allowed in the outer function.

Quick start

  1. Type f(x), for example x^2 + 1, and g(x), for example 2x - 3.
  2. Choose f(g(x)), g(f(x)) or both.
  3. To get a number, type an x value in the last box.

What f∘g means

(f ∘ g)(x) = f(g(x)). You read it from the inside out: first apply g to x, then apply f to the answer. The small circle is read as "composed with", and searches often write it as fog.

Worked example

Take f(x) = x² + 1 and g(x) = 2x − 3.

  • f(g(x)): replace each x in f with (2x − 3). That gives (2x − 3)² + 1 = 4x² − 12x + 9 + 1 = 4x² − 12x + 10.
  • g(f(x)): replace each x in g with (x² + 1). That gives 2(x² + 1) − 3 = 2x² − 1.

The two answers are different, which is normal: the order of composition matters.

Finding a value

For f(g(2)), work inside out. First g(2) = 2 × 2 − 3 = 1, then f(1) = 1² + 1 = 2. You can check it with the expanded form too: 4 × 4 − 12 × 2 + 10 = 2.

Domain of a composition

An x value works only if the inner function accepts it and the outer function accepts the inner function's output. With f(x) = 1/x and g(x) = x − 2, f(g(x)) = 1/(x − 2), so x = 2 is not allowed even though g(2) is fine on its own.

Inverse functions

If f(g(x)) = x and g(f(x)) = x, the two functions undo each other and are inverses. For example, f(x) = 3x + 2 and g(x) = (x − 2)/3 give x both ways.

Related calculators

Common questions

What does fog mean in maths?

fog, written f∘g, means f(g(x)): apply g first, then f to the result.

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

Usually not. With f(x) = x² + 1 and g(x) = 2x − 3, f(g(x)) = 4x² − 12x + 10 but g(f(x)) = 2x² − 1.

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

Work from the inside: find g(2) first, then put that answer into f.

Which functions can I enter?

Polynomials, fractions, roots and functions such as sqrt, sin, cos, ln and e^x, written in x.