Can anyone please explain and show (step by step) that how $ f \big( f ( x ) \big) = x $ in the following example?
One can show that for any Hamel basis $ H $ there exists a bijection $ \varphi : [ 0 , 1 ] \to H $. If we set $ \varphi ( t ) = h _ t $, then $ H = \{ h _ t | t \in [ 0 , 1 ] \} $. This observation leads to constructions of additive functions having interesting properties.
Example. Let $ f : \mathbb R \to \mathbb R $ be the additive function determined by the function $ s : H \to \mathbb R $ defined by: $$ s ( h _ t ) = \begin {cases} h _ t & \text {if } t \in \left[ 0 , \frac 1 2 \right] \\ - h _ t & \text {if } t \in \left( \frac 1 2 , 1 \right] \text . \end{cases} $$ Then it is easy to check that $ f \big( f ( x ) \big) = x $ for any $ x \in \mathbb R $.
Also, please explain and show (step by step) that how $ f \big( f ( x ) \big) = f ( x ) $ in the following example?
Another interesting example of a discontinuous additive function is obtained by considering the function $ s : H \to \mathbb R $ defined by $$ s ( h _ t ) = \begin {cases} h _ t & \text {if } t \in \left[ 0 , \frac 1 2 \right] \\ 0 & \text {if } t \in \left( \frac 1 2 , 1 \right] \text . \end{cases} $$ Then $ f \big( f ( x ) \big) = f ( x ) $ for any $ x \in \mathbb R $.
I was unable to do it and I am completely clueless.
For the first one, for all $h_t\in H$ we have
\begin{align} f(f(h_t)) = f(s(h_t)) &= \begin{cases} f(h_t) & t\le \frac 1 2 \\ f(-h_t) & t>\frac 1 2\end{cases} \\ &= \begin{cases} s(h_t) & t\le \frac 1 2 \\ -s(h_t) & t>\frac 1 2\end{cases} \\ &= \begin{cases} h_t & t\le \frac 1 2 \\ -(-h_t) & t>\frac 1 2\end{cases} \\ &= h_t. \end{align} Since $f(f(x))=x$ on a Hamel basis and both $f\circ f$ and $\operatorname{id}_{\mathbb R}$ are additive, it also holds on all of $\mathbb R$.
For the second one, for all $h_t\in H$ we have \begin{align} f(f(h_t)) = f(s(h_t)) &= \begin{cases} f(h_t) & t\le \frac 1 2 \\ f(0) & t>\frac 1 2\end{cases} \\ &= \begin{cases} s(h_t) & t\le \frac 1 2 \\ 0 & t>\frac 1 2\end{cases} \\ &= \begin{cases} h_t & t\le \frac 1 2 \\ 0 & t>\frac 1 2\end{cases} \\ &= s(h_t) = f(h_t). \end{align} Since $f(f(x))=f(x)$ on a Hamel basis and both $f\circ f$ and $f$ are additive, it also holds on all of $\mathbb R$.
In reply to questions raised in the comments: