Quick start
- Type f(x), for example x^2 + 1, and g(x), for example 2x - 3.
- Choose f(g(x)), g(f(x)) or both.
- 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
- Simplify & Expand Calculator: expand brackets, collect like terms and evaluate an expression in x at any value
- Online Graphing Calculator: draw one or more functions on shared axes and mark where they cross the x- and y-axes
- Derivative Calculator: exact derivatives of a function, up to the 8th, with the value at a chosen point
- Integral Calculator: exact antiderivatives of polynomials and the definite integral of any function between two limits
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.