TITLE: How to find $ f(x)$ if $f(1-f(x))=x$ for all $x$ $\in \mathbb{R}$
QUESTION [5 upvotes]: How can I determine $ f(x)$ if $f(1-f(x))=x$ for all real $x$? 
I have already recognized one problem caused from this: it 
follows that $ f(f(x))=1-x $, which is discontinuous. So how can I construct a function $f(x)$?
Best regards and thanks,
John

REPLY [7 votes]: This answer is heavily inspired by Adrian Keister's work.  Define
$$g(x):=f\left(x+\frac{1}{2}\right)-\frac12\text{ for each }x\in\mathbb{R}\,.$$
(Note that $f(x)=g\left(x-\dfrac12\right)+\dfrac12$ for all $x\in\mathbb{R}$.)
Thus,
$$\begin{align}g\big(-g(x)\big)&=f\left(-g(x)+\frac12\right)-\frac12\\&=f\Biggl(1-f\left(x+\frac{1}{2}\right)\biggr)-\frac12\\&=\left(x+\frac12\right)-\frac12=x\end{align}$$
for all $x\in\mathbb{R}$.  Thus, $g:\mathbb{R}\to\mathbb{R}$ is a bijection and
$$g^{-1}(x)=-g(x)\text{ for every }x\in\mathbb{R}\,.$$
Now,
$$\begin{align}g(x)+g(-x)&=g(x)+g\Big(-g\big(g^{-1}(x)\big)\Big)\\&=g(x)+g^{-1}(x)=g(x)-g(x)=0\end{align}$$
for all $x\in\mathbb{R}$.  That is, $g$ is an odd function, and so $g(0)=0$.  
In fact, $x=0$ is the only fixed point of $g$; for $g(t)=t$ implies
$$t=g\big(-g(t)\big)=g(-t)=-g(t)=-t\,.$$  Suppose also that $g(s)=-s$ for some $s\in\mathbb{R}$.  Then,
$$s=g\big(-g(s)\big)=g(s)=-s\,.$$
Therefore, $s=0$.
Let $a\neq 0$.  Suppose that $g(a)=b$ (noting that $b\neq a$ and $b\neq -a$).  We then have $$g(b)=-g(-b)=-g\big(-g(a)\big)=-a\,.$$  Thus, we have a pattern $$a\mapsto b\mapsto -a\mapsto -b\mapsto a$$ under $g$.  Therefore, the sets $$\big\{a,g(a),-a,-g(a)\big\}$$ form a partition of $\mathbb{R}_{\neq 0}$ into four-element subsets.  In fact, for any such a partition, there exists a function $g:\mathbb{R}\to\mathbb{R}$ with the required property.
Partition the set of nonzero real numbers into $4$-element subsets of the form $\{+a_\nu,+b_\nu,-a_\nu,-b_\nu\}$, where $\nu\in J$ for some index set $J$.  Take $$g(+a_\nu):=+b_\nu\,,\,\, g(+b_\nu):=-a_\nu\,,\,\,g(-a_\nu):=-b_\nu\,,\text{ and }g(-b_\nu):=+a_\nu$$ for every $\nu\in J$.  Then, $g$ satisfies the required functional equation.  In addition, we set $g(0):=0$.  For example, note that
$$\mathbb{R}_{\neq 0}=\bigcup_{k\in\mathbb{Z}_{\geq 0}}\,\bigcup_{\lambda\in(0,1]}\,\Big\{+a_{k,\lambda},+b_{k,\lambda},-a_{k,\lambda},-b_{k,\lambda}\Big\}$$
with $a_{k,\lambda}:=2k+\lambda$ and $b_{k,\lambda}:=2k+1+\lambda$ for all $k\in\mathbb{Z}_{\geq 0}$ and $\lambda\in(0,1]$.
It is easy to translate the result back to $f$.  All solutions $f:\mathbb{R}\to\mathbb{R}$ satisfying
$$f\big(1-f(x)\big)=x\text{ for all }x\in\mathbb{R}$$ 
can be retrieved as follows.  First, partition $\mathbb{R}_{\neq \frac{1}{2}}$ into $4$-element subsets of the form $$\left\{A_\nu,B_\nu,1-A_\nu,1-B_\nu\right\}\text{ for }\nu\in I\,,$$
where $I$ is an index set.  Then, take
$$f(A_\nu):=B_\nu\,,\,\,f(B_\nu):=1-A_\nu\,\,\,f(1-A_\nu):=1-B_\nu\,,\text{ and }f(1-B_\nu):=A_\nu$$
for every $\nu \in I$.  Finally, set $f\left(\dfrac12\right):=\dfrac12$.  For example, note that
$$\mathbb{R}_{\neq \frac12}=\bigcup_{k\in\mathbb{Z}_{\geq 0}}\,\bigcup_{\lambda\in(0,1]}\,\Big\{A_{k,\lambda},B_{k,\lambda},1-A_{k,\lambda},1-B_{k,\lambda}\Big\}$$
with $A_{k,\lambda}:=2k+\dfrac12+\lambda$ and $B_{k,\lambda}:=2k+\dfrac32+\lambda$ for all $k\in\mathbb{Z}_{\geq 0}$ and $\lambda\in(0,1]$.