1
$\begingroup$

I'm looking for a function $f : \mathbb{Z} \rightarrow \mathbb{Z}$ such that $f(f(x)) = x$ and $f(1) = 2$. In particular, I don't want this function to be a piecewise function. Does such a function even exist?


For example, I can define the above function as follows:

\begin{equation} f(x) = \begin{cases} 2 & x = 1 \\ 1 & x = 2 \end{cases} \end{equation}

However, I was wondering whether there's a way to define this function without writing conditions.

$\endgroup$
  • $\begingroup$ What exactly do you mean by "a piecewise function"? $\endgroup$ – Carl Schildkraut Sep 25 '16 at 6:56
  • 13
    $\begingroup$ $3-x{}{}{}{}{}$ $\endgroup$ – Gerry Myerson Sep 25 '16 at 6:57
  • $\begingroup$ @GerryMyerson Wow, that was simple. Why didn't that occur to me? $\endgroup$ – Aadit M Shah Sep 25 '16 at 7:01
  • 1
    $\begingroup$ @GerryMyerson how about putting that into answer? :) $\endgroup$ – Sil Sep 25 '16 at 7:09
  • $\begingroup$ @Sil, as you wish. $\endgroup$ – Gerry Myerson Sep 25 '16 at 13:36
3
$\begingroup$

$3-x$ (plus enough characters to qualify as an answer).

$\endgroup$
2
$\begingroup$

How about $f(x) = x-(-1)^x$? That works.

$\endgroup$
  • $\begingroup$ O.P. also wants f(f(x))=x though. $\endgroup$ – SquirtleSquad Sep 25 '16 at 6:59
  • $\begingroup$ @SquirtleSquad Sorry, I made a typo. This should work. $\endgroup$ – Carl Schildkraut Sep 25 '16 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.