This question already has an answer here:

I tried to look for a function that fulfills this rule; $$f(f(x))=\frac{1}{x}$$

I tried a lot, and I didn't find anything.

Can anyone help me find such a function? Or prove that there isn't? It doesn't have to be a real function.


marked as duplicate by Winther, Community Nov 11 '16 at 2:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Define $f$ on $\mathbb R\setminus\{0\}$ as:

$$f(x)=\begin{cases} -x&x>0\\ -\frac1x&x<0\\ \end{cases}$$

There are infinitely many similar functions - if $g:\mathbb R^+\to\mathbb R^+$ is any $1-1$ and onto function with $g(1/x)=1/g(x)$ then:

$$f(x)=\begin{cases} -g(x)&x>0\\ \frac{1}{g^{-1}(-x)}&x<0 \end{cases}$$

has this property.

  • $\begingroup$ Whoops, yes. @EricWofsey $\endgroup$ – Thomas Andrews Nov 11 '16 at 1:32
  • 1
    $\begingroup$ I would add that you can find many such $g$ by taking $g:(1,\infty)\to(1,\infty)$ to be any bijection and then extending $g$ to $(0,1)$ so that $g(1/x)=1/g(x)$ (and defining $g(1)=1$). You can even easily find many such $g$ that are continuous by requiring your bijection $(1,\infty)\to(1,\infty)$ to be order-preserving. $\endgroup$ – Eric Wofsey Nov 11 '16 at 1:34
  • $\begingroup$ @Eric Wofsey and finding such g would amount to answering the original question. $\endgroup$ – Anixx Nov 11 '16 at 1:34
  • 1
    $\begingroup$ Not sure what you mean by that, @Anixx. It's certainly not an "equally hard" problem - there are lots of simple examples of such a $g$, include $g(x)=x$ and $g(x)=1/x$. But $\endgroup$ – Thomas Andrews Nov 11 '16 at 1:36

There is no such function $f:\mathbb{C}\setminus\{0\}\to\mathbb{C}\setminus\{0\}$ that is continuous. Indeed, note that $x\mapsto 1/x$ induces multiplication by $-1$ on $\pi_1(\mathbb{C}\setminus\{0\})\cong\mathbb{Z}$, which cannot be $f_*\circ f_*$ for any homomorphism $f_*:\mathbb{Z}\to\mathbb{Z}$.

Similarly, there is no such continuous function $f:(0,\infty)\to(0,\infty)$, since $f$ would have to be injective and thus monotone, and then $f\circ f$ would be increasing no matter what.

You can get such a continuous function $f:\mathbb{R}\setminus\{0\}\to\mathbb{R}\setminus\{0\}$ by defining $$f(x)=\begin{cases}-x&\text{ if }x>0\\ -1/x&\text{ if } x<0.\end{cases}$$

Finally, if you don't require continuity, it is very easy to get such functions. Here's one way to do so. Just define $f(1)=1$, $f(-1)=-1$, and then partition the rest of the domain of $f$ into sets of the form $\{a,1/a,b,1/b\}$ (where these elements are all distinct). In each such set, define $f(a)=b$, $f(b)=1/a$, $f(1/a)=1/b$, and $f(1/b)=a$.

  • $\begingroup$ I do not see where in the question it is asked about everywhere continuous function. $\endgroup$ – Anixx Nov 11 '16 at 1:16
  • $\begingroup$ @Anixx The OP was not very restrictive about answers, so it is safe to make assumptions. $\endgroup$ – Simply Beautiful Art Nov 11 '16 at 1:16
  • 2
    $\begingroup$ It is totally excessive assumption. For instance, function $f(x)=i+\frac{2}{i + x}$ satisfies the conditions and it is discontinuous at only one point (the pole). $\endgroup$ – Anixx Nov 11 '16 at 1:17
  • 1
    $\begingroup$ The question was rather vague about what it is requiring, so I answered it in many different possible interpretations, including both a requirement of continuity and no such requirement. $\endgroup$ – Eric Wofsey Nov 11 '16 at 1:20

I think there is infinitely many such functions.

One such function that satisfies the conditions is

$$f(x)=i+\frac{2}{i + x}$$

  • 2
    $\begingroup$ @RossMillikan I just evaluated $f(f(x))$ by hand, and I got $1/x$. Anyways, you input wrong. It should be $$f(f(x))=i+\frac2{i+(i+\frac2{i+x})}$$ $\endgroup$ – Simply Beautiful Art Nov 11 '16 at 1:22
  • $\begingroup$ @Ross Millikan you can see the graphic yourself: wolframalpha.com/input/… $\endgroup$ – Anixx Nov 11 '16 at 1:23
  • 1
    $\begingroup$ You are correct. Sorry. $\endgroup$ – Ross Millikan Nov 11 '16 at 1:25

Assume that we have


Plugging this in gives


Thus, we have

$$n^2=-1\implies n=\pm i$$

Since these are complex exponents, we must be more careful. If we restrict $x$ to be positive, we have


where we use real valued logarithms. Thus,


  • $\begingroup$ :/ what is wrong with this answer? OP says complex functions are allowed. $\endgroup$ – Simply Beautiful Art Nov 11 '16 at 1:05
  • $\begingroup$ Complex exponentiation is not uniquely defined, and you must be careful with your choices of branch if you want to be sure $(x^i)^i=x^{-1}$ is always true. $\endgroup$ – Eric Wofsey Nov 11 '16 at 1:06
  • $\begingroup$ @EricWofsey Thanks for reminding me. :) $\endgroup$ – Simply Beautiful Art Nov 11 '16 at 1:12

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