How to use it
- Type f(x) and g(x), for example f(x) = x^2 + 1 and g(x) = 2x - 3.
- Read f(g(x)) and g(f(x)), each shown before and after expanding.
- 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²).