In short
The composite function (f \circ g)(x) = f(g(x)) is built by feeding the output of g into the input of f. The domain of f \circ g consists of all x in the domain of g such that g(x) lies in the domain of f. Composition is associative but generally not commutative: f \circ g \ne g \circ f in most cases.
A cloth merchant in Varanasi buys raw silk by weight. The price of raw silk depends on its grade, and the grade depends on the thread count per centimetre. So to get from thread count to price, you go through two steps: thread count \to grade \to price. Each step is a function. The combined process — thread count directly to price — is a composite function: the output of the first function becomes the input of the second.
This two-step chaining is everywhere. Converting Celsius to Fahrenheit and then Fahrenheit to Kelvin. Computing a student's percentage from raw marks and then converting percentage to a grade. Squaring a number and then taking its sine. In each case, you are not adding or multiplying two functions at the same input — you are piping one function's output into another function's input. That is composition.
The definition
Take two functions f and g. The composite function f \circ g (read "f composed with g," or "f of g") is defined by:
The process: start with x, apply g to get g(x), then apply f to that result to get f(g(x)).
Composition of Functions
Given f: B \to C and g: A \to B, the composite function f \circ g: A \to C is defined by
The notation matters. In f \circ g, g acts first and f acts second. The function written on the right is the one applied first. This is counterintuitive — it reads left-to-right but operates right-to-left. Hold on to this: in f \circ g, g goes first.
A concrete example: let f(x) = x^2 and g(x) = x + 3. Then:
And in the other order:
The results are different. (x+3)^2 = x^2 + 6x + 9 is not the same as x^2 + 3. This is the first important fact about composition: order matters.
Domain of a composite function
The domain of f \circ g is not simply the domain of g. There are two conditions:
- x must be in the domain of g (otherwise g(x) is not defined).
- g(x) must be in the domain of f (otherwise f(g(x)) is not defined).
Take f(x) = \sqrt{x} (domain [0, \infty)) and g(x) = 1 - x^2 (domain \mathbb{R}). Then:
Condition 1: x \in \mathbb{R} (always satisfied). Condition 2: g(x) = 1 - x^2 \ge 0, which gives x^2 \le 1, i.e., -1 \le x \le 1.
Domain of f \circ g: [-1, 1].
Here is another example. Let f(x) = \frac{1}{x} (domain \mathbb{R} \setminus \{0\}) and g(x) = x - 5 (domain \mathbb{R}). Then (f \circ g)(x) = \frac{1}{x-5}. Condition 1: x \in \mathbb{R}. Condition 2: g(x) = x - 5 \ne 0, i.e., x \ne 5. Domain: \mathbb{R} \setminus \{5\}.
Properties of composition
Composition is not commutative
You already saw this with f(x) = x^2 and g(x) = x + 3: (f \circ g)(x) = (x+3)^2 while (g \circ f)(x) = x^2 + 3. In general, f \circ g \ne g \circ f.
There are special cases where f \circ g = g \circ f — for instance, when f and g are both linear functions of the form ax + b with the same slope a = 1 (pure translations), or when one of them is the identity function \text{id}(x) = x. But these are exceptions, not the rule.
The identity function
The function \text{id}(x) = x is the identity for composition:
This is immediate: f(\text{id}(x)) = f(x) and \text{id}(f(x)) = f(x).
The identity function is to composition what the number 1 is to multiplication and what 0 is to addition — the element that leaves everything unchanged.
Composition is associative
This is the deepest property. Given three functions f, g, h:
The parentheses do not matter. Whether you first compose f with g and then compose the result with h, or first compose g with h and then compose f with the result, you get the same function.
The proof is direct. For any x in the appropriate domain:
Both expressions evaluate to f(g(h(x))). Since the two functions agree at every input, they are the same function.
Because composition is associative, you can write f \circ g \circ h without ambiguity — it means "apply h first, then g, then f." The same extends to any number of functions: f_1 \circ f_2 \circ \cdots \circ f_n is well-defined regardless of how you group the parentheses.
Two worked examples
Example 1: Find $(f \circ g)(x)$ and $(g \circ f)(x)$ for $f(x) = 2x + 1$ and $g(x) = x^2 - 3$, and determine their domains
Step 1. Compute (f \circ g)(x) = f(g(x)). Substitute g(x) = x^2 - 3 into f:
Why: replace the input of f (which is x) with the entire expression g(x) = x^2 - 3.
Step 2. Determine the domain of f \circ g. Domain of g: \mathbb{R} (polynomial). For every x \in \mathbb{R}, g(x) = x^2 - 3 is a real number, which lies in the domain of f (\mathbb{R}). So domain of f \circ g is \mathbb{R}.
Why: both conditions (x in domain of g, and g(x) in domain of f) are satisfied for all real x.
Step 3. Compute (g \circ f)(x) = g(f(x)). Substitute f(x) = 2x + 1 into g:
Why: replace the input of g with the expression f(x) = 2x + 1, then expand.
Step 4. Compare. (f \circ g)(x) = 2x^2 - 5 and (g \circ f)(x) = 4x^2 + 4x - 2. These are different quadratics — different leading coefficients, different linear terms, different constants.
Why: composition is not commutative. The order of application matters.
Result: (f \circ g)(x) = 2x^2 - 5 on \mathbb{R}. (g \circ f)(x) = 4x^2 + 4x - 2 on \mathbb{R}. They are not equal.
The picture makes the non-commutativity vivid. The two parabolas have different vertices, different widths, and different shapes — even though they are built from the same two functions.
Example 2: Find $(f \circ g)(x)$ and its domain for $f(x) = \frac{1}{x-2}$ and $g(x) = \sqrt{x}$
Step 1. Compute (f \circ g)(x) = f(g(x)). Substitute g(x) = \sqrt{x} into f:
Why: wherever f has x, replace it with \sqrt{x}.
Step 2. Apply condition 1: x must be in the domain of g. Since g(x) = \sqrt{x}, you need x \ge 0.
Why: the square root requires a non-negative input.
Step 3. Apply condition 2: g(x) must be in the domain of f. Since f requires its input \ne 2, you need \sqrt{x} \ne 2, i.e., x \ne 4.
Why: f has a denominator x - 2, and here the "input to f" is \sqrt{x}. So \sqrt{x} - 2 \ne 0.
Step 4. Combine the conditions. x \ge 0 and x \ne 4. In interval notation: [0, 4) \cup (4, \infty).
Why: intersect the two conditions. The domain is [0, \infty) with the single point 4 removed.
Result: (f \circ g)(x) = \frac{1}{\sqrt{x} - 2}, domain = [0, 4) \cup (4, \infty).
At x = 0, f(g(0)) = f(0) = \frac{1}{0-2} = -\frac{1}{2}. At x = 9, f(g(9)) = f(3) = \frac{1}{3-2} = 1. Both match the graph.
Common confusions
-
"(f \circ g)(x) means f(x) \cdot g(x)." The circle \circ is composition, not multiplication. (f \circ g)(x) = f(g(x)), not f(x) \cdot g(x). Multiplication combines outputs at the same input; composition chains one output into the next input.
-
"In f \circ g, f goes first." The opposite. In f \circ g, g is applied first and f is applied to the result. The function on the right of \circ acts first.
-
"The domain of f \circ g is the domain of g." Not always. You also need g(x) to lie in the domain of f. The domain of f \circ g can be strictly smaller than the domain of g.
-
"If f \circ g exists, then g \circ f also exists." The composition f \circ g requires the range of g to intersect the domain of f. The reverse composition g \circ f requires the range of f to intersect the domain of g. These are different conditions and one can hold without the other.
-
"Composition is commutative — I just need to be careful about the order." No amount of care makes it commutative. f \circ g and g \circ f are genuinely different functions in almost all cases. Being careful about order is correct; expecting the same answer either way is not.
Interactive: explore composition
The material above covers all of the composition content required for class 11 and most of JEE Main. The following sections explore two ideas that appear in JEE Advanced and beyond.
Decomposing functions
Composition also works in reverse: given a complicated function, you can break it into simpler parts. Take h(x) = \sqrt{x^2 + 1}. This is the composition f \circ g where g(x) = x^2 + 1 and f(t) = \sqrt{t}.
This decomposition is not unique. You could also write h = f \circ g with g(x) = x^2 and f(t) = \sqrt{t + 1}. Both decompositions are valid. The choice depends on what is useful — sometimes one decomposition makes a derivative easier to compute (this is exactly the chain rule in calculus).
Some standard decompositions:
| Composite | Inner g(x) | Outer f(t) |
|---|---|---|
| \sin(3x+2) | 3x + 2 | \sin t |
| e^{x^2} | x^2 | e^t |
| (2x-1)^5 | 2x - 1 | t^5 |
| \log(\sin x) | \sin x | \log t |
Composition and injectivity/surjectivity
Composition interacts with the key function properties in a structured way:
-
If both f and g are injective (one-to-one), then f \circ g is injective. The proof: if f(g(x_1)) = f(g(x_2)), then g(x_1) = g(x_2) (since f is injective), then x_1 = x_2 (since g is injective).
-
If both f and g are surjective (onto), then f \circ g is surjective. The proof: for any c in the codomain of f, there exists b with f(b) = c (since f is surjective), and there exists a with g(a) = b (since g is surjective). So f(g(a)) = c.
-
If both f and g are bijective, then f \circ g is bijective, and (f \circ g)^{-1} = g^{-1} \circ f^{-1}. Note the reversal of order — you undo the last step first, like removing layers in the reverse order you put them on. This connects directly to the article on inverse functions.
Self-composition and iteration
You can compose a function with itself: f \circ f, written f^2. More generally, f^n means f composed with itself n times:
For f(x) = 2x: f^2(x) = 2(2x) = 4x, f^3(x) = 2(4x) = 8x, and in general f^n(x) = 2^n x.
For f(x) = x^2: f^2(x) = (x^2)^2 = x^4, f^3(x) = (x^4)^2 = x^8, and in general f^n(x) = x^{2^n}.
Self-composition appears in the study of dynamical systems, fixed points, and iterative algorithms — topics well beyond class 11, but the seed is planted here.
Where this leads next
You now know how to compose functions, find the domain of a composite, and work with the key properties — especially non-commutativity and associativity. Here is where this connects.
- Inverse Functions — if f \circ g = \text{id} and g \circ f = \text{id}, then g is the inverse of f. Composition is how inverses are defined.
- Injective and Surjective Nature of Composites — when does f \circ g inherit injectivity or surjectivity from its parts?
- Algebra of Functions — the other way to combine functions: adding, subtracting, multiplying, and dividing their outputs.
- Types of Functions — injective, surjective, bijective — classifications that composition preserves or destroys.
- Functions — Definition and Notation — the foundational setup of domain, codomain, and function notation.