Why the Order of a Composite Function Matters
A function expression can describe more than one operation. In \(f(g(x))\), the input \(x\) is first used to calculate \(g(x)\); that result is then used as the input to \(f\). Reading the expression correctly means identifying this order before trying to evaluate it or reason about it.
This inside-out reading is useful throughout calculus. A complicated-looking expression often becomes easier to understand when it is separated into functions, each with a clear role. A nested-function diagram makes the order visible: it traces the input through the inner function and then through the outer function.
What Function Composition Means
Suppose \(g\) takes inputs from a set \(X\) to outputs in a set \(Y\), and \(f\) takes inputs from \(Y\) to outputs in a set \(Z\). The output of \(g\) can then be used as an input to \(f\). The resulting function is called the composition of \(f\) with \(g\).
The order of the function names in \(f\circ g\) can take a moment to get used to. The rightmost function, \(g\), acts first. The notation \(f(g(x))\) displays the same order: begin with the innermost expression \(x\), evaluate \(g\), and then evaluate \(f\).
For a composition to make sense at a particular input, two requirements must hold. First, \(x\) must be in the domain of \(g\). Second, the value \(g(x)\) must be an allowed input for \(f\). It is not enough for each formula to be familiar; the output of the inner function must fit the domain of the outer function.
A Reliable Way to Read the Notation
To identify the functions in a composite expression, look for the operation that receives the entire inner expression as its input. That operation is the outer function. The expression placed inside it determines the inner function. Then check the order by tracing the input from the innermost part outward.
Find the expression in the deepest, innermost position, usually \(x\).
Determine what operation acts directly on that input. This is the inner function.
Each outer operation takes the result of the preceding layer as its input.
Confirm that each intermediate result is an allowable input for the next function.
A nested-function diagram records those stages in order. Read its arrows from left to right: the input goes into the inner function first, and the final function produces the output.
Worked Example: Evaluating \(f(g(x))\) from the Inside Out
Worked Example: Evaluating \(f(g(2))\)
Let \(g(x)=x^2+3\) and \(f(t)=2t-1\). Identify the inner and outer functions, draw the order, and evaluate \(f(g(2))\).
The expression is \(f(g(2))\). The value \(2\) is inside \(g\), so \(g\) is applied first. The result is then used as the input to \(f\). Thus, \(g\) is inner and \(f\) is outer.
\(2\)
\(2\longmapsto g(2)\)
\(g(2)\longmapsto f(g(2))\)
First calculate the inner value:
Now use that result as the input to \(f\):
We can check by writing the composition as one expression. Since \(f(t)=2t-1\), replace its input \(t\) with \(g(x)=x^2+3\):
At \(x=2\), this gives \(2(2^2+3)-1=2(4+3)-1=14-1=13\), matching the inside-out calculation. The check confirms that the inner result was used as the outer function’s input.
Reading Trigonometric Expressions as Compositions
Standard function names can also serve as outer functions. In \(\sin(x^2+1)\), the sine function receives the entire expression \(x^2+1\) as its input. The inner function is \(g(x)=x^2+1\); the outer function is \(f(u)=\sin u\). The letter \(u\) is used here to show that the outer function takes a single input, which may be the output of another function.
In composition notation, the same expression is \((f\circ g)(x)\), where \(g(x)=x^2+1\) and \(f(u)=\sin u\). The notation does not say that sine and \(x^2+1\) are multiplied. It says that the output of \(g\) becomes the input of \(f\).
Worked Example: Identifying the Layers in \(\sin(x^2+1)\)
Identify the inner and outer functions, represent their order, and check the interpretation at \(x=1\).
The whole input to the sine function is \(x^2+1\), so take \(g(x)=x^2+1\) as the inner function and \(f(u)=\sin u\) as the outer function. The composition is \((f\circ g)(x)=f(g(x))=\sin(x^2+1)\).
The input is \(x\).
Calculate \(g(x)=x^2+1\).
Take the sine of the result: \(f(g(x))=\sin(x^2+1)\).
For the check, set \(x=1\). The inner function gives \(g(1)=1^2+1=2\). The outer function then gives \(f(2)=\sin 2\). Therefore \(f(g(1))=\sin 2\), which agrees with substituting directly into the original expression: \(\sin(1^2+1)=\sin 2\).
This example is about the structure and order of the expression. The key is that the entire quantity \(x^2+1\), not just \(x\), is the input to sine.
More Than Two Layers
A composition can contain several nested functions. Identify each layer separately, from the innermost operation to the outermost. Keeping the layers distinct is clearer than trying to treat a long expression as one undivided formula.
Worked Example: Sorting Three Nested Layers
Consider \(e^{\sin(x^2)}\). Identify the three functions and their order, then check the value at \(x=0\).
Start at the inside. First, \(x\) is squared. Next, the sine function acts on that square. Finally, the exponential function with base \(e\) acts on the sine value. Define the functions by \(h(x)=x^2\), \(g(u)=\sin u\), and \(f(v)=e^v\). The full expression is \((f\circ g\circ h)(x)\), meaning \(f(g(h(x)))\).
\(x\longmapsto h(x)=x^2\)
\(h(x)\longmapsto g(h(x))=\sin(x^2)\)
\(g(h(x))\longmapsto f(g(h(x)))=e^{\sin(x^2)}\)
Now evaluate each stage at \(x=0\). First, \(h(0)=0^2=0\). Second, \(g(h(0))=\sin(0)=0\). Third, \(f(g(h(0)))=e^0=1\). Thus the original expression at \(x=0\) is \(e^{\sin(0^2)}=e^{\sin 0}=e^0=1\), as the layer-by-layer evaluation shows.
The order is important: \(e^{\sin(x^2)}\) means square, then sine, then exponential. The diagram makes that sequence explicit.
Domain Requirements Are Part of the Reading
Identifying the layers also helps determine where a composition is defined. For a square root to produce a real number, its input must be nonnegative. In a composite expression, this condition applies to the value produced by the inner function.
Worked Example: Reading a Square-Root Composition and Its Domain
Consider \(\sqrt{5-2x}\). Identify the inner and outer functions, state the real domain, and check the value at \(x=1\).
Let \(g(x)=5-2x\) be the inner function and \(f(u)=\sqrt{u}\) be the outer function. The square-root function is defined for real inputs \(u\ge 0\), so the inner output must satisfy \(5-2x\ge 0\).
The real domain of the composite expression is therefore all real \(x\) with \(x\le 5/2\). To check at \(x=1\), first calculate \(g(1)=5-2(1)=3\). Then apply the outer function: \(f(3)=\sqrt{3}\). Direct substitution gives \(\sqrt{5-2(1)}=\sqrt{3}\), the same result. Also, \(1\le 5/2\), so this input lies in the domain.
Why the Inside-Out Order Is Required
The order is not merely a convenient reading habit; it follows from the definition of composition. Suppose \(g:X\to Y\) and \(f:Y\to Z\). To evaluate \(f(g(x))\), the value \(g(x)\) must exist first. Only then is there a specific value available to put into \(f\). The function \(f\) then returns an element of \(Z\).
This gives a direct justification for reading \(f(g(x))\) from the inside outward. The expression \(g(x)\) is itself the input written inside \(f\). Evaluating the outer function before the inner one would leave its input unspecified. The composition notation \(f\circ g\) records precisely this dependency: \(g\) must produce a value before \(f\) can act on it.
Composition order generally cannot be reversed. The expression \(g(f(x))\) describes a different sequence: apply \(f\) first, then \(g\). It may produce a different function or may not be defined for the same inputs. Thus, \(f\circ g\) and \(g\circ f\) should not be treated as interchangeable.
Common Mistake: Reversing the Functions
A common error is to say that \(f\) acts first in \(f(g(x))\) because its name appears first. That reverses the actual order. Here is a concrete example showing why the reversal changes the result.
Let \(g(x)=x+1\) and \(f(t)=t^2\). The correct inside-out evaluation at \(x=2\) is:
The mistaken reversed order would apply \(f\) to \(2\), then apply \(g\) to that result:
The answers, \(9\) and \(5\), are different. The correction is to begin with the innermost function in the expression as written: in \(f(g(2))\), evaluate \(g(2)\) first, then apply \(f\). The reversed calculation evaluates \(g(f(2))\), which is a different composition.
Do Not Confuse Composition with Similar Expressions
Parentheses and placement matter. Compare \(\sin(x^2+1)\) with \(\sin(x^2)+1\). In the first expression, \(x^2+1\) is the input to sine. In the second, \(x^2\) is the input to sine, and the \(+1\) is applied afterward. They have different layers.
For example, at \(x=0\), the first expression gives \(\sin(0^2+1)=\sin 1\), while the second gives \(\sin(0^2)+1=\sin 0+1=0+1=1\). The placements of the parentheses show which operations are inside the sine function.
Also distinguish composition from multiplication. The notation \(f(g(x))\) means “apply \(g\), then \(f\).” Multiplication of function values is written \(f(x)g(x)\), which means multiply the two outputs at the same input \(x\). These notations describe different operations.
Check Your Understanding
For each question, identify the functions and follow the order of evaluation carefully.
- For \(p(q(x))\), which function is applied first? Which is the outer function?
- In \(\cos(3x-4)\), identify an inner function and an outer function, and write the composition using function notation.
- Let \(g(x)=x^2-1\) and \(f(u)=u+5\). Evaluate \(f(g(2))\), showing the intermediate value.
- Draw or describe the order of the three layers in \(\sqrt{1+\sin x}\), from the innermost operation outward.
- Explain why \(f(g(x))\) and \(g(f(x))\) need not have the same value. Give a numerical example.