Composite Function Calculator

Evaluate f(g(x)) and g(f(x)) safely with visible intermediate values and no external JavaScript dependency.

Composite function calculator

Supports +, -, *, /, ^, parentheses, implicit multiplication such as 2x, constants pi and e, and sin, cos, tan, asin, acos, atan, sqrt, abs, exp, ln, and log.

f(g(4))

26

g(x) = 5, then f(g(x)) = 26

g(f(4))

31

f(x) = 17, then g(f(x)) = 31

Composite function calculator guide

Function composition uses the output of one function as the input of another. For f(g(x)), evaluate g at x first and then evaluate f at that result. Reverse the order for g(f(x)).

The order usually matters. This calculator evaluates numeric compositions with a restricted local expression parser. It does not download a math library, execute entered JavaScript, or claim to symbolically simplify a formula.

How to evaluate composite functions

  1. Enter f and g: Use x as the variable and the supported operators, constants, and one-argument functions listed below the fields.
  2. Enter x: Provide a finite numeric input that belongs to the domain of the inner functions.
  3. Evaluate: Select Evaluate compositions to compute both possible orders.
  4. Follow the intermediate value: Read the inner-function result before the final value to verify the substitution order.

Formula and variables

The inside function is evaluated first. Its output must belong to the domain of the outside function for the composition to be defined.

(f o g)(x) = f(g(x)); (g o f)(x) = g(f(x))
f, gFunctions
Rules that assign outputs to valid inputs.
xInitial input
The numeric value supplied to the inner function.
oComposition operator
Indicates that one function receives the output of another.

Composition is not commutative

Let f(x) = x^2 + 1, g(x) = 2x - 3, and x = 4.

f(x)
x^2 + 1
g(x)
2x - 3
x
4
  1. g(4) = 5, so f(g(4)) = f(5) = 26
  2. f(4) = 17, so g(f(4)) = g(17) = 31

Result: f(g(4)) = 26, while g(f(4)) = 31.

Changing the order changes the intermediate input and therefore changes the result.

Understanding your results

f(g(x))

The result of g is substituted for every x in f through numeric evaluation.

Domain errors

A square root of a negative number, logarithm of a nonpositive number, division by zero, or inverse-trigonometric input outside its real domain produces an error instead of a misleading number.

Assumptions

  • Functions are interpreted as real-valued expressions of one variable x.
  • Trigonometric inputs and outputs use radians.
  • log means base 10 and ln means the natural logarithm.
  • Both stages of a composition must produce finite real numbers.

Limitations

  • The calculator evaluates at one numeric x; it does not produce a symbolic composition formula.
  • Piecewise functions, factorials, matrices, complex results, user-defined functions, and multivariable expressions are not supported.
  • Implicit multiplication is supported for forms such as 2x and 3(x+1), but ambiguous notation should be written with an explicit operator.
  • Floating-point evaluation can introduce small rounding differences.

Common mistakes

  • Multiplying f(x) and g(x) instead of composing them.
  • Evaluating the outside function first.
  • Assuming f composed with g equals g composed with f.
  • Ignoring the domain of the outer function at the inner output.
  • Using degrees in trigonometric formulas when the parser uses radians.

Practical use cases

Algebra practice

Check the numeric substitution steps for two composition orders.

Model chains

Evaluate a two-stage model where the output of one relationship becomes the input of another.

Planning and decision guide

Check domains in both stages

For f(g(x)), x must be valid for g and g(x) must be valid for f. Repeat that reasoning separately for g(f(x)); one order can be defined even when the other is not.

Frequently asked questions

What does f(g(x)) mean?

Evaluate g at x, then use that output as the input to f.

Is composition the same as multiplication?

No. f(g(x)) generally differs from f(x) times g(x).

Does order matter?

Usually yes. Function composition is generally not commutative.

Which logarithms are supported?

Use ln for the natural logarithm and log for base 10.

Does this calculator simplify symbolic formulas?

No. It performs safe real-number evaluation at the entered x and reports intermediate numeric values.

Sources and review

Reviewed 2026-08-29.

Continue with calculators that answer nearby questions and help compare the next step.