In this collection we present 20 worked exercises on the composition of functions, of progressively increasing difficulty and with step-by-step explanations. The exercises deal with computing \(f\circ g\) and \(g\circ f\), the domain of a composite function, the order of composition, the identity function, associativity, and the interplay between composition and the inverse function.
The key idea to keep in mind is that in the composition \(f\circ g\) one applies \(g\) first and then \(f\). For every value of \(x\) at which the composition is defined, we have
\[ (f\circ g)(x)=f(g(x)). \]
Exercise 1 ā level ā āāāā
Let
\[ f(x)=2x+1,\qquad g(x)=x^2-3. \]
Compute \(f\circ g\).
Answer
The composite function is
\[ (f\circ g)(x)=2x^2-5. \]
Solution
To compute \(f\circ g\) we apply \(g\) first and then \(f\). By definition,
\[ (f\circ g)(x)=f(g(x)). \]
Since
\[ g(x)=x^2-3, \]
we substitute \(x^2-3\) for the variable in the expression for \(f\). As \(f(x)=2x+1\), we obtain
\[ f(g(x))=f(x^2-3)=2(x^2-3)+1. \]
Simplifying,
\[ 2(x^2-3)+1=2x^2-6+1=2x^2-5. \]
Hence
\[ (f\circ g)(x)=2x^2-5. \]
Exercise 2 ā level ā āāāā
Let
\[ f(x)=x^2,\qquad g(x)=x+4. \]
Compute \(f\circ g\) and \(g\circ f\).
Answer
The two compositions are
\[ (f\circ g)(x)=(x+4)^2 \]
and
\[ (g\circ f)(x)=x^2+4. \]
Solution
We first compute \(f\circ g\). By definition,
\[ (f\circ g)(x)=f(g(x)). \]
Since \(g(x)=x+4\), we obtain
\[ f(g(x))=f(x+4). \]
As \(f(x)=x^2\), substituting \(x+4\) for \(x\) gives
\[ f(x+4)=(x+4)^2. \]
Thus
\[ (f\circ g)(x)=(x+4)^2. \]
We now compute \(g\circ f\). Here we apply \(f\) first and then \(g\):
\[ (g\circ f)(x)=g(f(x)). \]
Since \(f(x)=x^2\), we obtain
\[ g(f(x))=g(x^2). \]
As \(g(x)=x+4\), this yields
\[ g(x^2)=x^2+4. \]
Therefore
\[ (g\circ f)(x)=x^2+4. \]
The two compositions do not coincide; this shows that, in general, the order of composition matters.
Exercise 3 ā level ā āāāā
Let
\[ f(x)=3x-2,\qquad g(x)=5x+1. \]
Compute \(f\circ g\) and \(g\circ f\).
Answer
The two compositions are
\[ (f\circ g)(x)=15x+1 \]
and
\[ (g\circ f)(x)=15x-9. \]
Solution
We compute \(f\circ g\):
\[ (f\circ g)(x)=f(g(x)). \]
Since \(g(x)=5x+1\), we obtain
\[ f(g(x))=f(5x+1). \]
As \(f(x)=3x-2\), substituting \(5x+1\) for \(x\) gives
\[ f(5x+1)=3(5x+1)-2. \]
Hence
\[ (f\circ g)(x)=15x+3-2=15x+1. \]
We now compute \(g\circ f\):
\[ (g\circ f)(x)=g(f(x)). \]
Since \(f(x)=3x-2\), we obtain
\[ g(f(x))=g(3x-2). \]
As \(g(x)=5x+1\), this gives
\[ g(3x-2)=5(3x-2)+1. \]
Simplifying,
\[ 5(3x-2)+1=15x-10+1=15x-9. \]
Thus
\[ (g\circ f)(x)=15x-9. \]
Exercise 4 ā level ā ā āāā
Let
\[ f(x)=x^2+1,\qquad g(x)=2x-3. \]
Compute \(f\circ g\) and \(g\circ f\).
Answer
The two compositions are
\[ (f\circ g)(x)=4x^2-12x+10 \]
and
\[ (g\circ f)(x)=2x^2-1. \]
Solution
We first compute \(f\circ g\):
\[ (f\circ g)(x)=f(g(x))=f(2x-3). \]
Since \(f(x)=x^2+1\), we obtain
\[ f(2x-3)=(2x-3)^2+1. \]
Expanding the square,
\[ (2x-3)^2+1=4x^2-12x+9+1=4x^2-12x+10. \]
Thus
\[ (f\circ g)(x)=4x^2-12x+10. \]
We now compute \(g\circ f\):
\[ (g\circ f)(x)=g(f(x))=g(x^2+1). \]
Since \(g(x)=2x-3\), substituting \(x^2+1\) for \(x\) gives
\[ g(x^2+1)=2(x^2+1)-3. \]
Hence
\[ (g\circ f)(x)=2x^2+2-3=2x^2-1. \]
Exercise 5 ā level ā ā āāā
Let
\[ f(x)=\sqrt{x},\qquad g(x)=x-4. \]
Find \(f\circ g\) and its real domain.
Answer
The composite function is
\[ (f\circ g)(x)=\sqrt{x-4} \]
and its real domain is
\[ \operatorname{Dom}(f\circ g)=[4,+\infty). \]
Solution
By definition,
\[ (f\circ g)(x)=f(g(x)). \]
Since \(g(x)=x-4\), we obtain
\[ f(g(x))=f(x-4). \]
As \(f(x)=\sqrt{x}\), this gives
\[ f(x-4)=\sqrt{x-4}. \]
Hence
\[ (f\circ g)(x)=\sqrt{x-4}. \]
To determine the real domain we require the radicand to be nonnegative:
\[ x-4\ge 0. \]
Solving,
\[ x\ge 4. \]
Therefore
\[ \operatorname{Dom}(f\circ g)=[4,+\infty). \]
Exercise 6 ā level ā ā āāā
Let
\[ f(x)=\frac{1}{x},\qquad g(x)=x^2-9. \]
Find \(f\circ g\) and its domain.
Answer
The composite function is
\[ (f\circ g)(x)=\frac{1}{x^2-9} \]
and its domain is
\[ \operatorname{Dom}(f\circ g)=\mathbb R\setminus\{-3,3\}. \]
Solution
The composite function is
\[ (f\circ g)(x)=f(g(x)). \]
Since \(g(x)=x^2-9\), we obtain
\[ f(g(x))=f(x^2-9). \]
As \(f(x)=1/x\), this gives
\[ f(x^2-9)=\frac{1}{x^2-9}. \]
Thus
\[ (f\circ g)(x)=\frac{1}{x^2-9}. \]
To find the domain we require the denominator to be nonzero:
\[ x^2-9\ne 0. \]
Solving,
\[ x^2-9=0 \quad \Longleftrightarrow \quad x^2=9. \]
Hence
\[ x=-3 \qquad \text{or} \qquad x=3. \]
These two values must be excluded from the domain.
Therefore
\[ \operatorname{Dom}(f\circ g)=\mathbb R\setminus\{-3,3\}. \]
Exercise 7 ā level ā ā āāā
Let
\[ f(x)=\sqrt{x+1},\qquad g(x)=\frac{1}{x}. \]
Find \(f\circ g\) and its real domain.
Answer
The composite function is
\[ (f\circ g)(x)=\sqrt{\frac{1}{x}+1} \]
and its real domain is
\[ \operatorname{Dom}(f\circ g)=(-\infty,-1]\cup(0,+\infty). \]
Solution
We compute the composite:
\[ (f\circ g)(x)=f(g(x)). \]
Since \(g(x)=1/x\), we obtain
\[ f(g(x))=f\left(\frac{1}{x}\right). \]
As \(f(x)=\sqrt{x+1}\), substituting \(1/x\) for \(x\) gives
\[ (f\circ g)(x)=\sqrt{\frac{1}{x}+1}. \]
For the domain we must impose two conditions. First, the inner function \(g(x)=1/x\) must be defined:
\[ x\ne 0. \]
Moreover, the argument of the square root must be nonnegative:
\[ \frac{1}{x}+1\ge 0. \]
Combining over a common denominator,
\[ \frac{1+x}{x}\ge 0. \]
The critical points are
\[ x=-1,\qquad x=0. \]
Analyzing the sign of the fraction, we obtain
\[ x\le -1 \qquad \text{or} \qquad x>0. \]
The value \(x=0\) is excluded because it makes the denominator vanish.
Therefore
\[ \operatorname{Dom}(f\circ g)=(-\infty,-1]\cup(0,+\infty). \]
Exercise 8 ā level ā ā āāā
Let
\[ f(x)=\frac{1}{x-1},\qquad g(x)=\sqrt{x}. \]
Find \(f\circ g\) and its real domain.
Answer
The composite function is
\[ (f\circ g)(x)=\frac{1}{\sqrt{x}-1} \]
and its real domain is
\[ \operatorname{Dom}(f\circ g)=[0,+\infty)\setminus\{1\}. \]
Solution
We compute:
\[ (f\circ g)(x)=f(g(x))=f(\sqrt{x}). \]
Since \(f(x)=1/(x-1)\), we obtain
\[ (f\circ g)(x)=\frac{1}{\sqrt{x}-1}. \]
For the domain we first require the inner function \(g(x)=\sqrt{x}\) to be defined:
\[ x\ge 0. \]
Moreover, the denominator of the composite function must be nonzero:
\[ \sqrt{x}-1\ne 0. \]
Solving,
\[ \sqrt{x}\ne 1. \]
Since \(\sqrt{x}=1\) if and only if \(x=1\), we must exclude \(x=1\).
Therefore
\[ \operatorname{Dom}(f\circ g)=[0,+\infty)\setminus\{1\}. \]
Exercise 9 ā level ā ā ā āā
Let
\[ f(x)=\sqrt{2-x},\qquad g(x)=x^2. \]
Find \(f\circ g\) and its real domain.
Answer
The composite function is
\[ (f\circ g)(x)=\sqrt{2-x^2} \]
and its real domain is
\[ \operatorname{Dom}(f\circ g)=[-\sqrt{2},\sqrt{2}]. \]
Solution
By definition,
\[ (f\circ g)(x)=f(g(x)). \]
Since \(g(x)=x^2\), we obtain
\[ f(g(x))=f(x^2). \]
As \(f(x)=\sqrt{2-x}\), this gives
\[ f(x^2)=\sqrt{2-x^2}. \]
Thus
\[ (f\circ g)(x)=\sqrt{2-x^2}. \]
For the real domain we require the radicand to be nonnegative:
\[ 2-x^2\ge 0. \]
This inequality is equivalent to
\[ x^2\le 2. \]
Hence
\[ -\sqrt{2}\le x\le \sqrt{2}. \]
Therefore
\[ \operatorname{Dom}(f\circ g)=[-\sqrt{2},\sqrt{2}]. \]
Exercise 10 ā level ā ā ā āā
Let
\[ f(x)=\frac{x^2-1}{x-1},\qquad g(x)=x+2. \]
Find \(f\circ g\) and its domain.
Answer
The composite function is
\[ (f\circ g)(x)=x+3 \qquad \text{for } x\ne -1. \]
Its domain is
\[ \operatorname{Dom}(f\circ g)=\mathbb R\setminus\{-1\}. \]
Solution
We compute the composite function:
\[ (f\circ g)(x)=f(g(x))=f(x+2). \]
We substitute \(x+2\) into the expression for \(f\):
\[ f(x+2)=\frac{(x+2)^2-1}{(x+2)-1}. \]
We simplify numerator and denominator:
\[ f(x+2)=\frac{x^2+4x+4-1}{x+1} =\frac{x^2+4x+3}{x+1}. \]
We factor the numerator:
\[ x^2+4x+3=(x+1)(x+3). \]
Hence, for \(x\ne -1\),
\[ \frac{x^2+4x+3}{x+1}=\frac{(x+1)(x+3)}{x+1}=x+3. \]
So the simplified expression for the composite is
\[ (f\circ g)(x)=x+3 \qquad \text{for } x\ne -1. \]
Nevertheless, the value \(x=-1\) must be excluded, since the denominator \(x+1\) appears in the expression before simplification. Equivalently, \(f\) is not defined when its argument equals \(1\). As the argument is \(x+2\), we must impose
\[ x+2\ne 1. \]
Hence
\[ x\ne -1. \]
Therefore
\[ \operatorname{Dom}(f\circ g)=\mathbb R\setminus\{-1\}. \]
Algebraic simplification does not remove the restriction on the domain.
Exercise 11 ā level ā ā āāā
Let
\[ f(x)=|x|,\qquad g(x)=x-2. \]
Compute \(f\circ g\) and \(g\circ f\).
Answer
The two compositions are
\[ (f\circ g)(x)=|x-2| \]
and
\[ (g\circ f)(x)=|x|-2. \]
Solution
We compute \(f\circ g\):
\[ (f\circ g)(x)=f(g(x))=f(x-2). \]
Since \(f(x)=|x|\), substituting \(x-2\) for \(x\) we obtain
\[ f(x-2)=|x-2|. \]
Hence
\[ (f\circ g)(x)=|x-2|. \]
We now compute \(g\circ f\):
\[ (g\circ f)(x)=g(f(x))=g(|x|). \]
Since \(g(x)=x-2\), we obtain
\[ g(|x|)=|x|-2. \]
Thus
\[ (g\circ f)(x)=|x|-2. \]
The two functions are different. For instance, when \(x=-1\),
\[ (f\circ g)(-1)=|-1-2|=3, \]
whereas
\[ (g\circ f)(-1)=|-1|-2=1-2=-1. \]
Exercise 12 ā level ā ā ā āā
Let
\[ f(x)=\sqrt{x},\qquad g(x)=x^2-1. \]
Find \(f\circ g\), \(g\circ f\), and their respective real domains.
Answer
We have
\[ (f\circ g)(x)=\sqrt{x^2-1},\qquad \operatorname{Dom}(f\circ g)=(-\infty,-1]\cup[1,+\infty), \]
while
\[ (g\circ f)(x)=x-1 \qquad \text{for } x\ge 0, \]
that is,
\[ \operatorname{Dom}(g\circ f)=[0,+\infty). \]
Solution
We first compute \(f\circ g\):
\[ (f\circ g)(x)=f(g(x))=f(x^2-1)=\sqrt{x^2-1}. \]
For the real domain we require
\[ x^2-1\ge 0. \]
Since
\[ x^2-1=(x-1)(x+1), \]
the inequality holds for
\[ x\le -1 \qquad \text{or} \qquad x\ge 1. \]
Hence
\[ \operatorname{Dom}(f\circ g)=(-\infty,-1]\cup[1,+\infty). \]
We now compute \(g\circ f\):
\[ (g\circ f)(x)=g(f(x))=g(\sqrt{x}). \]
Since \(g(x)=x^2-1\), we obtain
\[ g(\sqrt{x})=(\sqrt{x})^2-1=x-1. \]
The domain, however, is not all of \(\mathbb R\), because the inner function \(f(x)=\sqrt{x}\) is defined only for
\[ x\ge 0. \]
Therefore
\[ \operatorname{Dom}(g\circ f)=[0,+\infty). \]
This exercise shows that \(f\circ g\) and \(g\circ f\) may have different expressions and different domains.
Exercise 13 ā level ā ā ā āā
Let
\[ f:\mathbb R\to\mathbb R,\qquad f(x)=x^3-2x+1. \]
Compute \(f\circ\operatorname{id}_{\mathbb R}\) and \(\operatorname{id}_{\mathbb R}\circ f\).
Answer
We have
\[ f\circ\operatorname{id}_{\mathbb R}=f \]
and
\[ \operatorname{id}_{\mathbb R}\circ f=f. \]
Solution
The identity function on \(\mathbb R\) is defined by
\[ \operatorname{id}_{\mathbb R}(x)=x. \]
We compute the first composition:
\[ (f\circ\operatorname{id}_{\mathbb R})(x)=f(\operatorname{id}_{\mathbb R}(x)). \]
Since \(\operatorname{id}_{\mathbb R}(x)=x\), we obtain
\[ f(\operatorname{id}_{\mathbb R}(x))=f(x). \]
Hence
\[ f\circ\operatorname{id}_{\mathbb R}=f. \]
We now compute the second composition:
\[ (\operatorname{id}_{\mathbb R}\circ f)(x)=\operatorname{id}_{\mathbb R}(f(x)). \]
The identity function returns its own argument, so
\[ \operatorname{id}_{\mathbb R}(f(x))=f(x). \]
Therefore
\[ \operatorname{id}_{\mathbb R}\circ f=f. \]
The identity function is thus the neutral element with respect to composition.
Exercise 14 ā level ā ā ā āā
Let
\[ f(x)=x^2,\qquad g(x)=x+1,\qquad h(x)=2x. \]
Verify that
\[ (f\circ g)\circ h=f\circ(g\circ h). \]
Answer
The two compositions coincide and are both given by
\[ (2x+1)^2. \]
Solution
We first compute \((f\circ g)\circ h\). We determine \(f\circ g\):
\[ (f\circ g)(x)=f(g(x))=f(x+1). \]
Since \(f(x)=x^2\), we obtain
\[ (f\circ g)(x)=(x+1)^2. \]
Now we compose with \(h\):
\[ ((f\circ g)\circ h)(x)=(f\circ g)(h(x)). \]
Since \(h(x)=2x\), this gives
\[ (f\circ g)(h(x))=(f\circ g)(2x)=(2x+1)^2. \]
Hence
\[ ((f\circ g)\circ h)(x)=(2x+1)^2. \]
We now compute \(f\circ(g\circ h)\). We determine \(g\circ h\):
\[ (g\circ h)(x)=g(h(x))=g(2x)=2x+1. \]
Now we compose with \(f\):
\[ (f\circ(g\circ h))(x)=f((g\circ h)(x))=f(2x+1). \]
Since \(f(x)=x^2\), we obtain
\[ (f\circ(g\circ h))(x)=(2x+1)^2. \]
The two functions coincide. This confirms, in this specific instance, the associativity of composition.
Exercise 15 ā level ā ā ā āā
Let
\[ f:\mathbb R\to\mathbb R,\qquad f(x)=4x-7, \]
and
\[ g:\mathbb R\to\mathbb R,\qquad g(x)=\frac{x+7}{4}. \]
Verify by composition that \(g=f^{-1}\).
Answer
The function \(g\) is the inverse of \(f\), because
\[ g\circ f=\operatorname{id}_{\mathbb R} \]
and
\[ f\circ g=\operatorname{id}_{\mathbb R}. \]
Solution
To verify that \(g=f^{-1}\), we must check both compositions.
We first compute \(g\circ f\):
\[ (g\circ f)(x)=g(f(x)). \]
Since \(f(x)=4x-7\), we obtain
\[ g(f(x))=g(4x-7). \]
Substituting into the expression for \(g\),
\[ g(4x-7)=\frac{(4x-7)+7}{4}=\frac{4x}{4}=x. \]
Hence
\[ (g\circ f)(x)=x. \]
We now compute \(f\circ g\):
\[ (f\circ g)(x)=f(g(x)). \]
Since \(g(x)=\frac{x+7}{4}\), we obtain
\[ f(g(x))=f\left(\frac{x+7}{4}\right). \]
Substituting into the expression for \(f\),
\[ f\left(\frac{x+7}{4}\right)=4\cdot\frac{x+7}{4}-7=x+7-7=x. \]
Hence
\[ (f\circ g)(x)=x. \]
We have shown that
\[ g\circ f=\operatorname{id}_{\mathbb R} \qquad\text{and}\qquad f\circ g=\operatorname{id}_{\mathbb R}. \]
Therefore \(g=f^{-1}\).
Exercise 16 ā level ā ā ā āā
Let
\[ g(x)=x+2,\qquad f(x)=3x. \]
Compute \(f\circ g\) and find the inverse of the composite function.
Answer
The composite function is
\[ (f\circ g)(x)=3x+6 \]
and its inverse is
\[ (f\circ g)^{-1}(x)=\frac{x-6}{3}. \]
Solution
We compute the composite:
\[ (f\circ g)(x)=f(g(x)). \]
Since \(g(x)=x+2\), we obtain
\[ f(g(x))=f(x+2). \]
As \(f(x)=3x\), this gives
\[ f(x+2)=3(x+2)=3x+6. \]
Hence
\[ (f\circ g)(x)=3x+6. \]
Denote the composite function by
\[ h(x)=3x+6. \]
To find the inverse, we set
\[ y=3x+6. \]
We solve for \(x\). Subtracting \(6\) from both sides,
\[ y-6=3x. \]
Dividing by \(3\),
\[ x=\frac{y-6}{3}. \]
Hence
\[ h^{-1}(y)=\frac{y-6}{3}. \]
Renaming the independent variable,
\[ h^{-1}(x)=\frac{x-6}{3}. \]
Since \(h=f\circ g\), we obtain
\[ (f\circ g)^{-1}(x)=\frac{x-6}{3}. \]
Exercise 17 ā level ā ā ā ā ā
Let
\[ f(x)= \begin{cases} x+1 & \text{if } x\ge 0,\\ x^2 & \text{if } x<0, \end{cases} \qquad g(x)=x-2. \]
Find \(f\circ g\).
Answer
The composite function is
\[ (f\circ g)(x)= \begin{cases} (x-2)^2 & \text{if } x<2,\\ x-1 & \text{if } x\ge 2. \end{cases} \]
Solution
We must compute
\[ (f\circ g)(x)=f(g(x))=f(x-2). \]
The function \(f\) is defined piecewise. The branch to use depends on the sign of the argument of \(f\). Here the argument is not \(x\) but \(x-2\).
We therefore distinguish two cases.
If
\[ x-2\ge 0, \]
then
\[ x\ge 2. \]
In this case we use the first branch of \(f\), namely \(f(t)=t+1\). Hence
\[ f(x-2)=(x-2)+1=x-1. \]
If instead
\[ x-2<0, \]
then
\[ x<2. \]
In this case we use the second branch of \(f\), namely \(f(t)=t^2\). Hence
\[ f(x-2)=(x-2)^2. \]
Therefore
\[ (f\circ g)(x)= \begin{cases} (x-2)^2 & \text{if } x<2,\\ x-1 & \text{if } x\ge 2. \end{cases} \]
Exercise 18 ā level ā ā ā ā ā
Let
\[ g:A\to B,\qquad f:B\to C. \]
Prove that if \(g\) and \(f\) are injective, then \(f\circ g:A\to C\) is injective.
Answer
If \(g\) and \(f\) are injective, then \(f\circ g\) is injective as well.
Solution
To prove that \(f\circ g\) is injective, take two arbitrary elements \(x_1,x_2\in A\) and suppose they have the same image under \(f\circ g\):
\[ (f\circ g)(x_1)=(f\circ g)(x_2). \]
By the definition of composition, this equality becomes
\[ f(g(x_1))=f(g(x_2)). \]
Since \(f\) is injective, equality of the images forces equality of the arguments:
\[ g(x_1)=g(x_2). \]
Since \(g\) is injective as well, from \(g(x_1)=g(x_2)\) it follows that
\[ x_1=x_2. \]
We have shown that
\[ (f\circ g)(x_1)=(f\circ g)(x_2)\quad \Longrightarrow \quad x_1=x_2. \]
Hence \(f\circ g\) is injective.
Exercise 19 ā level ā ā ā ā ā
Let
\[ g:A\to B,\qquad f:B\to C. \]
Prove that if \(g\) and \(f\) are surjective, then \(f\circ g:A\to C\) is surjective.
Answer
If \(g\) and \(f\) are surjective, then \(f\circ g\) is surjective as well.
Solution
To prove that \(f\circ g\) is surjective, we must show that every element of \(C\) is the image of at least one element of \(A\) under \(f\circ g\).
So let \(z\in C\).
Since \(f:B\to C\) is surjective, there exists at least one element \(y\in B\) such that
\[ f(y)=z. \]
Since \(g:A\to B\) is surjective, there exists at least one element \(x\in A\) such that
\[ g(x)=y. \]
Then
\[ (f\circ g)(x)=f(g(x)). \]
Since \(g(x)=y\), we obtain
\[ (f\circ g)(x)=f(y). \]
But \(f(y)=z\), so
\[ (f\circ g)(x)=z. \]
We have found an element \(x\in A\) such that \((f\circ g)(x)=z\).
Since \(z\in C\) was arbitrary, every element of \(C\) is the image of at least one element of \(A\). Hence \(f\circ g\) is surjective.
Exercise 20 ā level ā ā ā ā ā
Let
\[ f(x)=\frac{1}{x-1},\qquad g(x)=\sqrt{x+2}. \]
Find \(f\circ g\), \(g\circ f\), and their respective real domains.
Answer
We have
\[ (f\circ g)(x)=\frac{1}{\sqrt{x+2}-1}, \qquad \operatorname{Dom}(f\circ g)=[-2,+\infty)\setminus\{-1\}. \]
Moreover,
\[ (g\circ f)(x)=\sqrt{\frac{1}{x-1}+2}, \qquad \operatorname{Dom}(g\circ f)=\left(-\infty,\frac{1}{2}\right]\cup(1,+\infty). \]
Solution
We first compute \(f\circ g\):
\[ (f\circ g)(x)=f(g(x))=f(\sqrt{x+2}). \]
Since \(f(x)=1/(x-1)\), we obtain
\[ (f\circ g)(x)=\frac{1}{\sqrt{x+2}-1}. \]
To determine the domain, we first require the inner function \(g(x)=\sqrt{x+2}\) to be defined:
\[ x+2\ge 0. \]
Hence
\[ x\ge -2. \]
Moreover, the denominator of the composite must be nonzero:
\[ \sqrt{x+2}-1\ne 0. \]
This condition is equivalent to
\[ \sqrt{x+2}\ne 1. \]
Since \(\sqrt{x+2}=1\) if and only if \(x+2=1\), we get \(x=-1\). Hence
\[ \operatorname{Dom}(f\circ g)=[-2,+\infty)\setminus\{-1\}. \]
We now compute \(g\circ f\):
\[ (g\circ f)(x)=g(f(x))=g\left(\frac{1}{x-1}\right). \]
Since \(g(x)=\sqrt{x+2}\), substituting \(1/(x-1)\) for \(x\) gives
\[ (g\circ f)(x)=\sqrt{\frac{1}{x-1}+2}. \]
For the domain we must first require \(f(x)=1/(x-1)\) to be defined:
\[ x-1\ne 0. \]
Hence
\[ x\ne 1. \]
Moreover, the argument of the square root must be nonnegative:
\[ \frac{1}{x-1}+2\ge 0. \]
Combining over a common denominator,
\[ \frac{1+2(x-1)}{x-1}\ge 0. \]
Simplifying the numerator,
\[ \frac{2x-1}{x-1}\ge 0. \]
The critical points are
\[ x=\frac{1}{2},\qquad x=1. \]
Analyzing the sign of the fraction, we obtain
\[ x\le \frac{1}{2} \qquad \text{or} \qquad x>1. \]
The value \(x=1\) remains excluded, since it makes the denominator vanish.
Therefore
\[ \operatorname{Dom}(g\circ f)=\left(-\infty,\frac{1}{2}\right]\cup(1,+\infty). \]
This exercise brings together the two fundamental aspects of composition: the order of application and the careful checking of the domain.