Why Composition Preserves Continuity
Suppose a map sends points of \(X\) into \(Y\), and a second map sends points of \(Y\) into \(Z\). Applying the first map and then the second produces a map from \(X\) to \(Z\). The key question is whether the continuity of each stage guarantees continuity of the whole process. The answer follows from tracking open sets backwards through the two maps.
Throughout, \((X,\mathcal{T}_X)\), \((Y,\mathcal{T}_Y)\), and \((Z,\mathcal{T}_Z)\) denote topological spaces. A map \(f:X\to Y\) is continuous if \(f^{-1}(V)\) is open in \(X\) for every open set \(V\) in \(Y\). For maps \(f:X\to Y\) and \(g:Y\to Z\), their composition \(g\circ f:X\to Z\) is defined by \((g\circ f)(x)=g(f(x))\).
Proof. Let \(W\) be any open subset of \(Z\). Since \(g\) is continuous, \(g^{-1}(W)\) is open in \(Y\). Since \(f\) is continuous, the preimage under \(f\) of this open set is open in \(X\). For each \(x\in X\), \(x\in f^{-1}(g^{-1}(W))\) holds exactly when \(f(x)\in g^{-1}(W)\), which holds exactly when \(g(f(x))\in W\). Thus \[ (g\circ f)^{-1}(W)=f^{-1}(g^{-1}(W)), \] and this set is open in \(X\). This is true for every open \(W\subseteq Z\), so \(g\circ f\) is continuous. If one of the spaces is empty, the same argument applies: the preimage of an open set is still open, including when it is empty. \(\square\)
The order in this identity is important: points are mapped first by \(f\) and then by \(g\), while sets are pulled back first by \(g\) and then by \(f\). Continuity is suited to this backwards movement because it says precisely that preimages of open sets remain open.
Continuity at a Point
The same reasoning has a local form. A map \(f:X\to Y\) is continuous at \(x\in X\) if, for every open neighborhood \(V\) of \(f(x)\), there is an open neighborhood \(U\) of \(x\) such that \(f(U)\subseteq V\). This definition lets us check a composite near one input without assuming either map is continuous everywhere.
Proof. Let \(W\) be any open neighborhood of \(g(f(x))\). Since \(g\) is continuous at \(f(x)\), there is an open neighborhood \(V\) of \(f(x)\) such that \(g(V)\subseteq W\). Since \(f\) is continuous at \(x\), there is an open neighborhood \(U\) of \(x\) such that \(f(U)\subseteq V\). Therefore \(g(f(U))\subseteq g(V)\subseteq W\). By the definition of continuity at a point, \(g\circ f\) is continuous at \(x\). \(\square\)
In particular, if both maps are continuous everywhere, the pointwise result applies at every \(x\in X\). The open-set proof above gives the global conclusion directly and is often the quickest way to verify it.
Worked Example: Composing Real-Valued Maps
Give \(\mathbb{R}\) its standard topology. Define \(f:\mathbb{R}\to\mathbb{R}\) by \(f(x)=2x-3\), and \(g:\mathbb{R}\to\mathbb{R}\) by \(g(y)=y^2\). Compute \(g\circ f\) and verify continuity of both maps.
For an input \(x\), first \(f(x)=2x-3\). Applying \(g\) to that output gives \[ (g\circ f)(x)=g(2x-3)=(2x-3)^2=4x^2-12x+9. \] For example, at \(x=2\), \(f(2)=2(2)-3=1\), then \(g(1)=1^2=1\). The expanded expression gives \(4(2^2)-12(2)+9=16-24+9=1\), agreeing with the two-stage calculation.
To check continuity directly with the Euclidean metric, fix \(x_0\in\mathbb{R}\) and \(\varepsilon>0\). If \(|x-x_0|<\varepsilon/2\), then \[ |f(x)-f(x_0)|=|(2x-3)-(2x_0-3)|=2|x-x_0|<\varepsilon. \] Thus \(f\) is continuous at every \(x_0\).
For \(g\), fix \(y_0\in\mathbb{R}\) and \(\varepsilon>0\). Choose \[ \delta=\min\left(1,\frac{\varepsilon}{2|y_0|+1}\right)>0. \] If \(|y-y_0|<\delta\), then \(|y-y_0|<1\), so \(|y+y_0|\leq |y-y_0|+2|y_0|<2|y_0|+1\). Hence \[ |g(y)-g(y_0)|=|y^2-y_0^2|=|y-y_0||y+y_0| <\delta(2|y_0|+1)\leq\varepsilon. \] So \(g\) is continuous at every \(y_0\). The composition theorem now ensures that \(g\circ f\) is continuous.
Check: At \(x=0\), the two-stage evaluation is \(f(0)=-3\), followed by \(g(-3)=9\). Substitution into \(4x^2-12x+9\) gives \(4(0)^2-12(0)+9=9\), as required.
Compositions When the Topologies Differ
The composition theorem does not require metric spaces, or even require that the spaces use the same topology. Each continuity claim is tested using the topology on its own domain and codomain. The following examples make those choices explicit.
Worked Example: From the Real Line to a Sierpinski Space
Let \(X=\mathbb{R}\) with its standard topology. Let \(Y=\{a,b\}\) have topology \(\{\varnothing,\{a\},Y\}\), and let \(Z=\{u,v\}\) have the indiscrete topology \(\{\varnothing,Z\}\). Define \(f:X\to Y\) by \(f(x)=a\) when \(x>0\) and \(f(x)=b\) when \(x\leq 0\). Define \(g:Y\to Z\) by \(g(a)=v\) and \(g(b)=u\).
To check \(f\), take each open set of \(Y\). The preimages of \(\varnothing\), \(\{a\}\), and \(Y\) are respectively \(\varnothing\), \((0,\infty)\), and \(\mathbb{R}\). Each is open in the standard topology on \(X\), so \(f\) is continuous. The only open sets of \(Z\) are \(\varnothing\) and \(Z\), whose preimages under \(g\) are \(\varnothing\) and \(Y\). Both are open in \(Y\), so \(g\) is continuous.
The composite is \(g(f(x))=v\) for \(x>0\), and \(g(f(x))=u\) for \(x\leq 0\). Its continuity can also be checked directly: the preimage of the open set \(\varnothing\) is \(\varnothing\), and the preimage of the open set \(Z\) is \(X\). Both are open in \(X\).
Check: At \(x=-1\), \(f(-1)=b\) and \(g(b)=u\). At \(x=2\), \(f(2)=a\) and \(g(a)=v\). These evaluations agree with the stated cases for the composite. Notice that the continuity tests use the specific topologies on \(Y\) and \(Z\), not a metric on those sets.
Worked Example: A Finite Discrete Domain and a Metric Intermediate Space
Let \(X=\{r,s,t\}\) have the discrete topology, in which every subset is open. Let \(Y=\mathbb{R}\) with its standard topology, and let \(Z=\{a,b\}\) have topology \(\{\varnothing,\{a\},Z\}\). Define \(f:X\to Y\) by \(f(r)=-2\), \(f(s)=0\), and \(f(t)=3\). Define \(g:Y\to Z\) by \(g(y)=a\) for \(y>0\) and \(g(y)=b\) for \(y\leq 0\).
For any open \(V\subseteq Y\), \(f^{-1}(V)\) is a subset of \(X\), and every subset of the discrete space \(X\) is open. Thus \(f\) is continuous. For \(g\), the preimages of the three open sets \(\varnothing\), \(\{a\}\), and \(Z\) are \(\varnothing\), \((0,\infty)\), and \(\mathbb{R}\), respectively. All are open in \(Y\), so \(g\) is continuous.
Evaluating in order gives \((g\circ f)(r)=g(-2)=b\), \((g\circ f)(s)=g(0)=b\), and \((g\circ f)(t)=g(3)=a\). In particular, the strict condition \(y>0\) sends \(3\) to \(a\), whereas the value \(0\) belongs to the \(y\leq 0\) case and is sent to \(b\). The preimages of the open sets of \(Z\) under the composite are \(\varnothing\), \(\{t\}\), and \(X\). Each is open in the discrete topology, verifying continuity directly.
Check: The set \(\{t\}\) is open in \(X\), and it is exactly the set of inputs whose composite output is \(a\). This is the preimage of the only nonempty proper open set of \(Z\), as required by the definition of continuity.
Composition Order and a Common Pitfall
Composition is not commutative: in general, \(g\circ f\) is not \(f\circ g\). Moreover, the expression \(f\circ g\) may not even be defined. If \(f:X\to Y\) and \(g:Y\to Z\), then \(g\circ f\) is defined because the output of \(f\) lies in the domain of \(g\). Reversing the order would require \(g\) to output points in the domain of \(f\).
Common pitfall. In the first worked example, it would be wrong to write \((g\circ f)(x)=g(x) \) followed by \(f\), or to compute \(f(g(x))\) instead. At \(x=2\), the correct order gives \(f(2)=1\), then \(g(1)=1\). Reversing the order gives \(g(2)=4\), then \(f(4)=2(4)-3=5\). The values \(1\) and \(5\) differ, so the reversed calculation is not the composite \(g\circ f\).
There is a separate caution about reversing the composition theorem: continuity of a composite does not imply that both component maps are continuous. For a concrete example, let \(X=Y=Z=\mathbb{R}\) with their standard topologies. Define \(f(x)=0\) for \(x\leq0\) and \(f(x)=1\) for \(x>0\), and define \(g(y)=0\) for every \(y\). The map \(f\) is not continuous, because the preimage of the open interval \((-1/2,1/2)\) is \((-\infty,0]\), which is not open in \(\mathbb{R}\). The map \(g\) is continuous: the preimage of any open set is either \(\mathbb{R}\) or \(\varnothing\). Yet \(g\circ f\) is the constant-zero map and is continuous, since its preimage of any open set is either all of \(\mathbb{R}\) or empty. Thus the theorem is a guarantee when both maps are continuous, not a test that can be reversed.
Check Your Understanding
For each question, keep track of the domain and codomain topology at every stage.
- If \(f:X\to Y\) and \(g:Y\to Z\) are continuous, write the preimage identity that proves \(g\circ f\) is continuous.
- In the first worked example, compute \((g\circ f)(-1)\) using both the two-stage definition and the expanded formula.
- For \(Y=\{a,b\}\) with topology \(\{\varnothing,\{a\},Y\}\), determine whether the map \(h:\mathbb{R}\to Y\) defined by \(h(x)=a\) for \(x\geq0\) and \(h(x)=b\) for \(x<0\) is continuous. Check the preimage of each open set.
- Give the local-neighborhood argument showing that continuity of \(f\) at \(x\) and of \(g\) at \(f(x)\) implies continuity of \(g\circ f\) at \(x\).
- Why does continuity of \(g\circ f\) alone not guarantee continuity of \(f\)? Use the constant-composite example to explain.