ΣCalculator Solver
Algebra

Function Composition Calculator (f∘g)

Find (f∘g)(x) = f(g(x)) and (g∘f)(x) = g(f(x)) for any two functions, with the result expanded and both compositions evaluated at a number, step by step. Also called a fog and gof calculator.

f(x) = x^2 + 1, g(x) = 2x - 3
(f∘g)(x) = f(g(x))
Replace every x in f with g(x): (2x - 3)^2 + 1
f(g(x)) = 4 * x ^ 2 - 12 * x + 10
(g∘f)(x) = g(f(x))
Replace every x in g with f(x): 2(x^2 + 1) - 3
g(f(x)) = 2 * x ^ 2 - 1
At x = 2
g(2) = 1, then f(1) = 2
f(g(2)) = 2
f(2) = 5, then g(5) = 7
g(f(2)) = 7
Order matters: f(g(x)) and g(f(x)) are usually different.

How to use it

  1. Type f(x) and g(x), for example f(x) = x^2 + 1 and g(x) = 2x - 3.
  2. Read f(g(x)) and g(f(x)), each shown before and after expanding.
  3. Optionally enter a value of x to evaluate both compositions one step at a time.

What function composition means

(f∘g)(x), read "f of g of x" and often typed as fog, means you apply g first and then apply f to the result: f(g(x)). (g∘f)(x), or gof, applies f first.

Worked example

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

At x = 2: g(2) = 1, so f(g(2)) = f(1) = 2. And f(2) = 5, so g(f(2)) = g(5) = 7.

Order matters

In general f(g(x)) ≠ g(f(x)), as the example shows. Composition is not like multiplication, where the order does not change the answer.

Domain

f(g(x)) is only defined where g(x) is defined and where its output is allowed in f. For f(x) = √x and g(x) = x − 4, f(g(x)) = √(x − 4) needs x ≥ 4.

Frequently asked questions

What does fog mean in math?

fog is shorthand for f∘g, the composition f(g(x)): apply g first, then f.

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

Usually not. Swap the order and you generally get a different function.

How do I evaluate f(g(3))?

Find g(3) first, then put that number into f.

Can I compose trig or exponential functions?

Yes. For example f(x) = sin(x) and g(x) = x^2 give f(g(x)) = sin(x²).