Function Composition

Evaluate f(g(x)), g(f(x)), f(f(x)), and g(g(x)) for two functions. Free online composition calculator for algebra and calculus with step-by-step evaluation.

Compose functions

About This Calculator

This Function Composition Calculator lets you compose two functions f and g and evaluate f(g(x)), g(f(x)), f(f(x)), and g(g(x)) at a given value of x. Simply enter the expressions for f(x) and g(x) using standard mathematical notation, provide an x value, and click Calculate. The calculator handles four composition variants simultaneously, giving you a complete picture of how the functions interact and whether composition is commutative for your specific pair.

The calculator parses expressions using JavaScript's Math API, supporting operations like +, -, *, /, ^ (exponentiation), and functions including sin(), cos(), tan(), sqrt(), log(), ln(), exp(), abs(), asin(), acos(), and atan(), plus the constants pi and e. It evaluates compositions step-by-step: first computing the inner function value at the given x, then plugging that output into the outer function. For f(g(x)), the calculator evaluates g(x) first and passes the result to f. For g(f(x)), it reverses the order, demonstrating that composition is generally not commutative. The calculator also computes f(f(x)) and g(g(x)), showing iterative application of each function.

Function composition appears across many branches of mathematics. In calculus, it underpins the chain rule for differentiating composite functions. In algebra, it helps with transformations and inverse function verification. In computer science, the same concept appears in functional programming pipelines and function chaining. In physics and engineering, composite models describe systems where one quantity depends on another through multiple stages. Students preparing for JEE Advanced, AP Calculus, SAT Math, and A-Level exams can use this tool to check their work and explore how function composition behaves with different function pairs.

India (IN): Function composition is covered in CBSE Class 12 mathematics under Relations and Functions. It is a key concept for JEE Advanced, especially for composite function problems and functional equations.

United States (US): Composition of functions is taught in Algebra 2 and Precalculus. Students learn to evaluate composite functions, find domains of compositions, and apply the chain rule in AP Calculus AB/BC.

United Kingdom (UK): A-Level Mathematics covers composite functions in Pure Mathematics. Students learn to find fg(x) and gf(x), understand that composition is non-commutative, and determine domains and ranges of composite functions.

Frequently Asked Questions

What is function composition?

Function composition is applying one function to the results of another. If f and g are functions, then f(g(x)) means first compute g(x), then apply f to that result. Similarly, g(f(x)) means compute f(x) first, then apply g. Composition is not commutative: f(g(x)) generally does not equal g(f(x)).

How do you compose two functions?

To compose f with g, evaluate the inner function g at x to get g(x), then evaluate the outer function f at the value g(x). For example, if f(x) = x^2 and g(x) = x + 1, then f(g(x)) = (x+1)^2 = x^2 + 2x + 1, and g(f(x)) = x^2 + 1.

Is function composition commutative?

No, function composition is generally not commutative. f(g(x)) is typically different from g(f(x)). For example, if f(x) = 2x and g(x) = x^2, then f(g(x)) = 2x^2 but g(f(x)) = 4x^2. Only in special cases like f(x) = g(x) = x do they commute.

What is the domain of a composite function?

The domain of f(g(x)) consists of all x in the domain of g such that g(x) is in the domain of f. In other words, x must be a valid input to g, and g(x) must be a valid input to f. The calculator checks this by evaluating both steps and reporting undefined for invalid inputs.

What mathematical operators are supported?

The calculator supports: +, -, *, /, ^ (exponentiation), sin(), cos(), tan(), asin(), acos(), atan(), sqrt(), abs(), log()/ln() (natural log), exp(), and the constants pi and e. Write expressions like 'x^2 + 3*x - 1' or 'sin(x^2)'.

Why is function composition important in calculus?

Function composition is fundamental to the chain rule in calculus, which states that the derivative of f(g(x)) is f'(g(x)) · g'(x). Understanding composition also helps with inverse functions, transformations, and modeling composite real-world processes where one quantity depends on another.