Function Composition Calculator
Calculate the composition of two functions (f∘g)(x) and (g∘f)(x) with step-by-step algebraic solutions using our free online function composition calculator.
The Function Composition Calculator helps you calculate the composition of two functions $f(x)$ and $g(x)$. It computes both $(f \circ g)(x)$ and $(g \circ f)(x)$ with detailed step-by-step algebraic solutions, showing each substitution and simplification along the way. This free online tool is ideal for students learning function composition, teachers preparing examples, and anyone wanting to verify their algebraic work.
What is Function Composition?
Function composition is the process of combining two functions to create a new function. When we compose functions $f$ and $g$, we write it as $(f \circ g)(x)$, which is read as "$f$ composed with $g$" or "$f$ of $g$ of $x$."
The notation $(f \circ g)(x)$ means $f(g(x))$, where:
- First, apply the inner function $g$ to the input $x$, getting $g(x)$
- Then, apply the outer function $f$ to that result, getting $f(g(x))$
- The inner function is always applied first, then the outer function
How to Calculate Function Composition
To find $(f \circ g)(x) = f(g(x))$, follow these steps:
Step 1: Identify the Inner and Outer Functions
In $(f \circ g)(x)$, $g$ is the inner function (applied first) and $f$ is the outer function (applied second). The notation reads right to left in terms of application order.
Step 2: Substitute $g(x)$ into $f(x)$
Replace every occurrence of $x$ in $f(x)$ with the entire expression for $g(x)$. For example, if $f(x) = 2x + 3$ and $g(x) = x^2 - 1$, then substitute to get $f(g(x)) = 2(x^2 - 1) + 3$.
Step 3: Simplify
Expand, combine like terms, factor, or otherwise simplify the resulting expression. In the example above: $2(x^2 - 1) + 3 = 2x^2 - 2 + 3 = 2x^2 + 1$.
Step 4: Write the Final Answer
Express your result as $(f \circ g)(x) = \text{simplified expression}$.
Important Properties of Function Composition
Function Composition is NOT Commutative
In general, $(f \circ g)(x) \neq (g \circ f)(x)$. The order of composition matters significantly. For example, if $f(x) = 2x + 1$ and $g(x) = x^2$, then $(f \circ g)(x) = 2x^2 + 1$, but $(g \circ f)(x) = 4x^2 + 4x + 1$. These are completely different functions.
Function Composition is Associative
If you have three functions $f$, $g$, and $h$, then $f \circ (g \circ h) = (f \circ g) \circ h$. This means the grouping does not matter when composing three or more functions.
Identity Function
The identity function $I(x) = x$ satisfies $(f \circ I)(x) = (I \circ f)(x) = f(x)$ for any function $f$.
Inverse Functions
If $f$ and $g$ are inverse functions, then $(f \circ g)(x) = x$ and $(g \circ f)(x) = x$. This is the defining property of inverse functions. You can verify this using our Inverse Function Calculator.
Domain of Composite Functions
The domain of $(f \circ g)(x)$ consists of all $x$ in the domain of $g$ such that $g(x)$ is in the domain of $f$. In other words, you must check two conditions:
- $x$ must be in the domain of the inner function $g$
- $g(x)$ must be in the domain of the outer function $f$
For example, if $f(x) = \sqrt{x}$ and $g(x) = x - 4$: $g(x)$ is defined for all real numbers, but $f(x) = \sqrt{x}$ requires $x \geq 0$. For $(f \circ g)(x) = \sqrt{x - 4}$, we need $x - 4 \geq 0$, so $x \geq 4$. You can explore domain analysis further with our Domain and Range Calculator.
Worked Examples
Example 1: Polynomial Functions
Let $f(x) = 2x + 3$ and $g(x) = x^2 - 1$. Find $(f \circ g)(x)$.
Solution:
- $(f \circ g)(x) = f(g(x))$
- Substitute $g(x) = x^2 - 1$ into $f(x) = 2x + 3$:
- $f(x^2 - 1) = 2(x^2 - 1) + 3$
- $= 2x^2 - 2 + 3$
- $= 2x^2 + 1$
Example 2: Rational and Polynomial Functions
Let $f(x) = \frac{1}{x}$ and $g(x) = x + 2$. Find both $(f \circ g)(x)$ and $(g \circ f)(x)$.
Solution:
- $(f \circ g)(x) = f(g(x)) = f(x + 2) = \frac{1}{x + 2}$
- $(g \circ f)(x) = g(f(x)) = g\left(\frac{1}{x}\right) = \frac{1}{x} + 2 = \frac{1 + 2x}{x}$
- Notice that $(f \circ g)(x) \neq (g \circ f)(x)$, demonstrating non-commutativity
Example 3: Verifying Inverse Functions
Let $f(x) = 2x + 3$ and $g(x) = \frac{x - 3}{2}$. Verify that $f$ and $g$ are inverses.
Solution:
- $(f \circ g)(x)$: $f\left(\frac{x - 3}{2}\right) = 2 \cdot \frac{x - 3}{2} + 3 = x - 3 + 3 = x$ ✓
- $(g \circ f)(x)$: $g(2x + 3) = \frac{(2x + 3) - 3}{2} = \frac{2x}{2} = x$ ✓
- Since both compositions equal $x$, $f$ and $g$ are inverses
Applications of Function Composition
In Calculus
Function composition is essential for the chain rule in differentiation. If $h(x) = f(g(x))$, then $h'(x) = f'(g(x)) \cdot g'(x)$. Use our Limit Calculator to explore the foundational concepts of calculus.
In Real-World Problems
Function composition models sequential processes such as temperature conversion (Fahrenheit to Celsius then to Kelvin), business operations (applying a discount then adding tax), and physics calculations.
How to Use This Calculator
Using the Function Composition Calculator is straightforward:
- Enter your first function in the f(x) = input field
- Enter your second function in the g(x) = input field
- The calculator instantly computes $(f \circ g)(x)$ (displayed in blue) and $(g \circ f)(x)$ (displayed in green)
- View the detailed step-by-step solution in the output area below the results
- Click any example button to load pre-defined function pairs and see how composition works
Supported Functions and Syntax
The calculator supports a wide range of mathematical expressions:
- Polynomials: $x^2 + 2x + 1$
- Rational functions: $(x-1)/(x+2)$
- Radical functions: $\sqrt{x}$ — write as
sqrt(x) - Exponential functions: $e^x$ — write as
e^xorexp(x) - Logarithmic functions: $\ln(x)$ — write as
log(x)orln(x) - Trigonometric functions: $\sin(x), \cos(x), \tan(x)$
Implicit multiplication is supported — writing 2x is equivalent to 2*x.
Use parentheses to clarify the order of operations for complex expressions.
For visualizing your functions, try our Function Grapher to see their graphs on an interactive coordinate system. If you need to check whether a function is even, odd, or neither, use our Function Odd Even Neither Checker.
Frequently Asked Questions
What is the difference between $(f \circ g)(x)$ and $f(x) \times g(x)$?
$(f \circ g)(x)$ is function composition, meaning $f(g(x))$ — you apply $g$ first, then $f$ to the result. In contrast, $f(x) \times g(x)$ is function multiplication, where you multiply the outputs of both functions evaluated at the same input. These are completely different operations that produce different results.
How do I read the notation $(f \circ g)(x)$?
Read it as "$f$ composed with $g$ of $x$" or simply "$f$ of $g$ of $x$." The small circle $\circ$ indicates composition, not multiplication.
Does order matter in function composition?
Yes, function composition is not commutative. $(f \circ g)(x)$ usually gives a different result than $(g \circ f)(x)$. Always pay attention to which function is applied first. Our calculator computes both compositions side by side so you can compare them directly.
How do I find the domain of a composite function?
The domain of $(f \circ g)(x)$ consists of all $x$-values where: (1) $x$ is in the domain of $g$, and (2) $g(x)$ is in the domain of $f$. You must check both conditions. For example, if $f(x) = \sqrt{x}$ and $g(x) = x^2 - 9$, then $g$ is defined everywhere, but $(f \circ g)(x) = \sqrt{x^2 - 9}$ requires $x^2 - 9 \geq 0$, giving domain $x \leq -3$ or $x \geq 3$.
What happens when I compose a function with its inverse?
When $f$ and $g$ are inverse functions, $(f \circ g)(x) = x$ and $(g \circ f)(x) = x$ for all $x$ in their respective domains. The composition of inverse functions returns the original input. This is the defining property of inverse functions and is used to verify that two functions are inverses.
Can I compose more than two functions?
Yes, function composition is associative, meaning $f \circ (g \circ h) = (f \circ g) \circ h$. You can compose any number of functions by applying them sequentially from right to left. While our calculator handles two functions at a time, you can compute three-way compositions by composing two functions first, then composing the result with the third function.