intuition behind the construction of the map for showing associativity of $\pi_1(X,x_0)$. I am studying algebraic topology.I have started with the chapter on fundamental group.Fundamental group at $x_0$ is defined to be the set of all equivalence classes of loops based at $x_0$ together with composition of two classes of loops.Now I am trying to show that this indeed forms a group.Now for associativity of this set,one has to show that $f.(g.h)\simeq(f.g).h$.Now  we have,
$(f.g).h(s)=\begin{cases} f(4s),\text{if } 0\leq s\leq 1/4\\g(4s-1),\text{if }1/4\leq s\leq 1/2\\h(2s-1),\text{if }1/2\leq s\leq 1\end{cases}$
and,
$f.(g.h)(s)=\begin{cases} f(2s),\text{if } 0\leq s\leq 1/2\\g(4s-2),\text{if }1/2\leq s\leq 3/4\\h(4s-3),\text{if }3/4\leq s\leq 1\end{cases}$
Now the author of the text gives a homotopy between these two loops as follows:
$H:[0,1]\times [0,1]\to X$ given by,
$H(s,t)=\begin{cases} f(\frac{4s}{1+t}),\text{if } 0\leq s\leq (1+t)/4\\g(4s-t-1),\text{if }(1+t)/4\leq s\leq (2+t)/4\\h(\frac{4s-2-t}{2-t}),\text{if }(2+t)/4\leq s\leq 1\end{cases}$
Now this seems to have come out of blue.I tried to think but could not find a way how this can be constructed.I am looking for a clear intuition behind this construction.
 A: The difference between $(f\cdot g)\cdot h$ and $f\cdot(g\cdot h)$ is not the "path" they follow, but the "speed" in which they follow said paths. So we want a homotopy that (continuously) change the speed in some parts of the loop. For instance, observe that $(f\cdot g)\cdot h$ does the full loop of $f$ in $[0,\frac{1}{4}]$, by means of $f(4s)$, but $f\cdot(g\cdot h)$ does the full lop of $f$ in $[0,\frac{1}{2}]$, by means of $f(2s)$ (you can see this as if the speed of $(f\cdot g)\cdot h$ is double the speed of $f\cdot(g\cdot h)$, in the first part of the path). So we want to change $4s$ continuously into $2s$. One way to do that is, as in the homotopy you presented:
$$[0,1]\ni t\mapsto \frac{4s}{1+t}.$$
But we also need to change the interval in wich $f$ is traversed (the interval we need to do the full loop of $f$), initially it is $[0,\frac{1}{4}]$ and we change it (continuously) to $[0,\frac{1}{2}]$, in such way that in every step of the way (every $t\in[0,1]$) $f$ is traversed. Can you see why the interval is $[0,\frac{1+t}{4}]$?
Next, we can se that $g$ is traversed whit the same speed, what changes is when we begin to traverse $g$. So we want to change $4s-1$ into $4s-2$ and $[\frac{1}{4},\frac{1}{2}]$ into $[\frac{1}{2},\frac{3}{4}]$.
The reasoning for $h$ is a bit more complex because not only it changes when $h$ starts to be traversed, but it also change the speed in which we do that. But it's done just as in the previous cases: we need to change $2s-1$ to $4s-3$ and $[\frac{1}{2},1]$ to $[\frac{3}{4},1]$ in a way that we traverse $h$ completely in every step of the way.
You don't have to follow the exact formula of this text, i encourage you to try and come up with your own homotopy.
