Gluing Topological Spaces to Themselves
 Definition: Let $Z$ be a topological space and let $X$ and $Y$ be disjoint subspaces of $Z$. Let $f : X \to Y$ be a surjective map where $f(X) = Y$ is the range of $f$. Define an equivalence relation $\sim$ on $Z$ by $a \sim b$ if $f(a) = b$ and $x \sim x$ for all $x \in Z$. Then the equivalence classes of $\sim$ are $\{ \{ y \} \cup f^{-1}(y) \}$ where $y \in Y$ and singleton sets $\{ y \}$ where $y \in Y$. The resulting space denoted $Z_f$ is called the Gluing of $X$ and $Y$ along $f$.
For example, consider the space $Z = [0, 3]$ and let $X, Y \subset Z$ be given by $X = [0, 1]$ and $Y = [2, 3]$. Define a function $f : X \to Y$ by $f(x) = 3 - x$. Then the resulting space $Z_f$ can be illustrated as: