Let \(f,g,h\) be continuous maps from \(X\) to \(Y\text{.}\) We assume \(f\simeq g\) and \(g\simeq h\text{.}\) By definition there is a homotopy \(F\) from \(f\) to \(g\text{,}\) and a homotopy \(G\) from \(g\) to \(h\text{.}\) Define
\begin{align*}
H(x,t) \amp =\begin{cases}
F(x,2t) \amp \text{if } t\in [0,1/2]\\
G(x,2t) \amp \text{if } t\in [1/2, 1]
\end{cases}\text{.}
\end{align*}
The functions \(F(x,2t)\) and \(G(x,2t-1)\) are continuous on the closed sets \(X\times [0,1/2]\) and \(X\times [1/2, 1]\text{,}\) respectively, and agree on the intersection \(X\times \{1/2\}\) since \(F(x,2(1/2))=F(x,1)=g(x)\) and \(G(x,2(1/2)-1)=G(x,0)=g(x)\) for all \(x\in X\text{,}\) by definition of homotopy. By the closed pasting lemma, we conclude that \(H\) is well-defined and continuous. Lastly, we have
\begin{align*}
H(x,0) \amp =F(x,0)=f(x)\\
H(x,1) \amp =G(x,1)=g(x)
\end{align*}
for all \(x\in X\text{.}\)