Evaluate at an input value
Use x, numbers, + - * / ^, parentheses, sqrt(), log(), exp(), abs(), sin(), cos(), and tan(). Each function is limited to 240 characters.
Use this Function Composition Calculator to enter values, adjust options, and review results in a compact responsive workspace.
Results are calculated automatically as you enter data.
Use x, numbers, + - * / ^, parentheses, sqrt(), log(), exp(), abs(), sin(), cos(), and tan(). Each function is limited to 240 characters.
▼ See explanations and tips below ▼
Function composition is the process of using the output of one function as the input of another function. Instead of applying two functions separately, composition connects them into one ordered chain.
If \(g\) is applied first and \(f\) is applied second, the composite function is written as:
This is read as “\(f\) composed with \(g\)” or “\(f\) of \(g\) of \(x\).” The expression inside the parentheses, \(g(x)\), is evaluated first. Its output then becomes the input for \(f\).
That inside-to-outside order is the central idea. In \(f(g(x))\), the function \(g\) does not come second just because it appears later in the notation. It is the inner function, so it acts first.
Function composition is useful whenever one quantity depends on another intermediate quantity. For example, the cost of heating a home may depend on temperature, and temperature may depend on the day of the year. A composite function lets you connect those relationships in one expression.
Function composition helps turn multi-step relationships into clear mathematical models. It appears throughout algebra, precalculus, calculus, science, economics, computer science, and many applied fields.
Students often meet composition when learning function notation, inverse functions, transformations, and derivatives. Later, it becomes important for the chain rule in calculus, where a function inside another function must be handled carefully.
Composition also helps avoid a common algebra mistake: assuming that changing the order of operations gives the same result. In many cases, \(f(g(x))\) and \(g(f(x))\) are different functions and produce different values.
To compose two functions, substitute the entire inner function wherever the input variable appears in the outer function.
For two functions \(f\) and \(g\):
The reverse order is:
These two expressions usually are not the same:
The basic process is:
Domain is especially important. For \(f(g(x))\), the input \(x\) must be allowed by \(g\), and the resulting value \(g(x)\) must be allowed by \(f\). In set notation:
This means the domain of a composite function is not always just the domain of the inner function or the outer function by itself. The output of the inner function has to fit the outer function.
Let:
To find \(f(g(x))\), substitute \(g(x)\) into \(f\):
Since \(f\) doubles its input and adds \(3\):
So:
At \(x = 4\):
Using the same functions:
Now reverse the order and find \(g(f(x))\):
Since \(g\) squares its input:
At \(x = 4\):
So at \(x = 4\):
The same two functions give different results because they were applied in a different order.
Let:
To evaluate \(f(g(h(9)))\), start with the innermost function:
Then apply \(g\):
Then apply \(f\):
Therefore:
A stage-by-stage view is often the clearest way to understand longer compositions.
Let:
Then:
The natural logarithm is defined only for positive inputs, so the expression inside the logarithm must be greater than \(0\):
So the composite function is defined only when \(x > 2\). Even though \(g(x) = x - 2\) works for every real number, the composite function has a smaller domain because the output of \(g\) must be valid for \(f\).
The composed expression shows the selected function chain after substitution. For example, if the selected order is \(f\) after \(g\), the expression represents \(f(g(x))\).
The value at \(x\) is the final numeric output after all functions in the selected chain have been applied. It is not always the value of \(f(g(x))\) unless the selected order is specifically \(f\) after \(g\).
The selected order should be read from inside to outside. A label such as “\(f\) after \(g\)” means \(g\) is evaluated first and \(f\) is evaluated second:
The comparison between \(f(g(x))\) and \(g(f(x))\) is useful for seeing whether changing the order changes the result at the chosen input. If the calculator marks the two values as the same, that means the numeric outputs match within its comparison tolerance for that specific \(x\) value. It does not prove that the two composite functions are identical for every possible input.
Stage values show the path from the original input through each function. For a chain such as \(f(g(h(x)))\), the stages help you see \(x\), then \(h(x)\), then \(g(h(x))\), and finally \(f(g(h(x)))\).
Full-domain notes are heuristic warnings about possible restrictions; they are not a complete symbolic domain solution. At the selected input, the calculator validates square roots, logarithms, zero denominators, tangent poles, non-finite stages, and the indeterminate form (0^0).
Numeric output may be rounded for display. Ordinary finite values are shown to a limited number of decimal places, and very large or very small values may appear in exponential notation. If a result is undefined or not finite, review the domain and the intermediate stage values.
Mistake 1: Reversing the order.
In \(f(g(x))\), \(g\) is evaluated first because it is inside the parentheses. The phrase “\(f\) after \(g\)” means apply \(g\) first, then apply \(f\).
Mistake 2: Assuming \(f(g(x))\) and \(g(f(x))\) are always equal.
Function composition is generally order-sensitive. The two compositions may match in special cases or at a particular input, but they usually represent different function chains.
Mistake 3: Substituting only part of the expression.
When composing functions, replace every occurrence of \(x\) in the outer function with the full inner expression. If \(f(x) = x^2 + x\) and \(g(x) = x - 1\), then:
Both copies of \(x\) in \(f\) must be replaced.
Mistake 4: Ignoring domain restrictions.
A composite function can fail even when the original input works in the inner function. The inner output must also be allowed by the outer function.
Mistake 5: Treating a numeric match as a symbolic identity.
If two compositions give the same value at one input, that does not mean the formulas are the same for all inputs. A full identity requires algebraic reasoning over the relevant domain.
Mistake 6: Misreading logarithms and trigonometric inputs.
In this calculator, log and ln are treated as natural logarithms. Trigonometric functions such as sin, cos, and tan use radians, not degrees.
Mistake 7: Using unsupported notation.
Use decimal points instead of decimal commas, and use only the supported variable \(x\). Multi-variable functions, comma-separated function arguments, matrices, vectors, piecewise definitions, and unsupported function names are outside this calculator’s scope.
Use function composition when you want to:
Composition is especially helpful when a problem naturally has stages. The output of one step becomes the input of the next step.
A function composition calculator is a learning and checking tool, not a full symbolic algebra system. It can show substitution, evaluate a selected input, and display intermediate stages, but it may not simplify every expression the way a computer algebra system or a handwritten algebra solution might.
This calculator is designed for one-variable functions using \(x\). It supports common operations and elementary functions such as sqrt, log, ln, exp, abs, sin, cos, and tan. It does not support variables other than \(x\), multivariable functions, piecewise functions, matrices, vectors, inequalities, or arbitrary user-defined function names.
The available composition orders are limited to the supported choices, including \(f(g(x))\), \(g(f(x))\), \(f(f(x))\), \(g(g(x))\), \(f(g(h(x)))\), and \(h(g(f(x)))\).
The domain scan is heuristic. It can flag obvious possible restrictions, but it does not solve the exact domain of every composite function. For classwork, tests, proofs, or formal domain answers, work through the domain conditions directly.
Because the calculator evaluates numerically, results can be affected by finite-precision arithmetic and display rounding. Values close to a tangent pole are treated as undefined. A “same” comparison between \(f(g(x))\) and \(g(f(x))\) means the displayed numeric results are close enough under the calculator’s tolerance at that input. It does not prove symbolic equality.
For repeated compositions, enter valid expressions carefully. A blank or invalid required expression can prevent the calculation from running even if the selected order appears to emphasize another function.
The inner function is evaluated first. In \(f(g(x))\), calculate \(g(x)\) first, then use that result as the input for \(f\).
Usually, no. Function composition is generally order-dependent, so reversing the order often changes both the formula and the numeric result. They can be the same for special functions or at specific input values, but that must be checked rather than assumed.
For \(f(g(x))\), first make sure \(x\) is allowed in \(g\). Then make sure the output \(g(x)\) is allowed in \(f\). Any value that fails either condition must be excluded from the domain of the composite function.
A composition becomes undefined when one of the stages produces an invalid input for the next stage. Common causes include division by zero, a negative value inside an even root, a nonpositive value inside a logarithm, or a tangent input where tangent is not defined.
log mean base 10 or natural logarithm?
In this calculator, log and ln are treated as natural logarithms. The natural logarithm uses base \(e\). Do not assume log means base \(10\) here.
They use radians. For example, an input of \(\pi\) represents \(180^\circ\), and an input of \(\frac{\pi}{2}\) represents \(90^\circ\).
It means the two numeric results are close enough at the selected \(x\) value under the calculator’s tolerance. It does not prove that \(f(g(x))\) and \(g(f(x))\) are the same function for every \(x\).
It can display the substituted composition and evaluate it numerically, but it is not a complete symbolic simplification tool. For exact simplification, identities, and formal domain work, verify the algebra separately.