How function composition works
1. Identify the order
In f(g(x)), g is inside the parentheses, so evaluate g first. The result becomes the input of f.
2. Substitute the rule
To write a composed rule, replace every x in f(x) with the entire expression g(x). Parentheses preserve the intended operations.
3. Check both domains
The original input must be allowed by g, and g(x) must be an allowed input for f. Either condition can make the composition undefined.
4. Keep the order
Composition is generally not commutative: f(g(x)) and g(f(x)) often have different rules and values.
Definition
(f ∘ g)(x) = f(g(x))
For f(x)=2x+3 and g(x)=x²−1, substitution gives f(g(x))=2(x²−1)+3. At x=4, first find g(4)=15, then f(15)=33.
Composition examples and domain checks
Linear after quadratic
If f(x)=3x−2 and g(x)=x²+1, then f(g(x))=3(x²+1)−2=3x²+1.
Radical outer function
If f(x)=sqrt(x), then the inner output must be nonnegative. For g(x)=x−5, the real composition requires x≥5.
Reciprocal inner function
If g(x)=1/x, then x=0 is excluded before the outer function is evaluated.
Order changes the result
With f(x)=x+1 and g(x)=x², f(g(x))=x²+1, while g(f(x))=(x+1)².
Accuracy, privacy, and limits
The calculator parses a restricted mathematical grammar and evaluates it locally; it does not use JavaScript eval and does not send function rules or values to a server. Intermediate and final calculations use browser floating-point arithmetic and display up to 12 significant digits.
Inputs are limited to 180 characters, 240 expression nodes, 40 levels of nesting, and |x|≤10¹². Undefined real operations—such as division by zero, sqrt(−1), ln(0), or a non-real power—produce an error instead of a misleading result. The composed expression is substitution form, not a full symbolic simplification. Last reviewed: 4 August 2026.
Function composition FAQs
What does f(g(x)) mean?
It means apply g to x first, then apply f to the output. It is also written (f∘g)(x).
Is f(g(x)) the same as g(f(x))?
Usually not. Reversing the order changes which function receives the original input and can change both the value and the allowed domain.
How do I create the composed rule?
Replace every occurrence of x in the outer rule f(x) with the full inner rule g(x). Put the inner rule in parentheses when needed.
Why is my composition undefined?
The input may cause division by zero or an invalid logarithm or root in g. Alternatively, g may return a value outside the domain of f. The error message identifies which stage failed.
Does log mean base 10 or base e?
log(x) means base 10, while ln(x) means the natural logarithm. Both require a positive real input.
Are trigonometric inputs in degrees?
No. The calculator uses radians, matching the standard JavaScript mathematical functions. For example, enter pi/2 for 90 degrees.