# $f:X\rightarrow X$ such that $f(f(x))=x$

Let $X$ be a metric space and $f:X\rightarrow X$ be such that $f(f(x))=x$, for all $x\in X$.

Then $f$

1. is one-one and onto;
2. is one-one but not onto;
3. is onto but not one-one;
4. need not be either.

From the given condition I have that $f^2=i$ where $i$ is the identity function. If $f$ itself is the identity function then the conditions are satisfied as well as $f$ is bijection. Is that the only such function or are there other possibilities ?

My guess is that it will be bijection i.e. option $1$ will be correct .

For see, if $$f(x_1)=y \ \text{and}\ f(x_2)=y \ \text{then} \ f(y)=x_1\ \text{and}\ f(y)=x_2$$ will be possible iff $x_1=x_2$. So this is injective.

Now an injection from a set to itself is trivially surjective so it is bijective. Is my proof correct?

• $\exp(x)$ is injective $\mathbb{R} \to \mathbb{R}$ but is not surjective – Henry Sep 29 '16 at 7:23
• Lots of opitions. f (x)=-x. f (x) = 1/x;if n!=0,f (x)=0;if x=0. For {q_i} any enumeration of the rationals f (q_2k)= 2k+1, while f (q_2k+1)= q_2k for rational f (x)=1/x if x irrational, etc. – fleablood Sep 29 '16 at 8:00
• You proof of injective is good. Surjective not. – fleablood Sep 29 '16 at 8:03
• If $X$ is finite, then the injectivity of $f$ implies the surjectivity of $f$ also. However, when $X$ is infinite, this is no longer necessarily true. – Transcendental Sep 29 '16 at 10:10
• For surjective: Obviously $X = i(X) = f(f(X))\subseteq f(X)\subseteq X$. – celtschk Oct 15 '16 at 8:07

Hint: For any two functions $f:Y\to Z$ and $g:X\to Y$, can

1. $f\circ g$ be onto if $g$ isn't?
2. $f\circ g$ be one-to-one if $f$ isn't?
• thank you . but my proof is correct is not it? – user118494 Sep 29 '16 at 7:18
• An injection from a set to itself is only bijective iff said set is finite (in fact, that's one way to define "finite set"). So you need to check surjectivity on its own. – Arthur Sep 29 '16 at 7:21
• I know. $y$ is the image of $f(y)$ right? – user118494 Sep 29 '16 at 7:36
• @user118494 Your proof is not correct as a number of people have pointed out already. There are many injections from a set into itself which are not surjective. They can even be extremely unsurjective consider $\epsilon \arctan(x)$. What do you mean by $y$ is the image of $f(y)$. if you're saying $f(f(y))=y$ that's just your premise. If you're saying $f(y)=y$ than that is not necessarily true. – DRF Sep 29 '16 at 7:45
• @user118494 Yes, that's correct. – Arthur Sep 29 '16 at 8:19

Injective.

If $f (x)=f (y)$ then $x=f (f (x))=f (f (y)l=y$, so injective.

Surjective:

If $y \in X$. Then $f (y)=x \in X$. So $f (x)=f (f (y))=y$, so surjective.

It really is that simple.

===

But there's more than just f =identity. Lots more.

Pick any such $f$ and any $a,b;a\ne b$ and define $g (a)=b, g (b)=a; g(x)=f (x)$ if $x \ne a;x\ne b$.

Here's a convoluted one. Let $\{q_i\}$ be any enumeration of the rational numbers. Let $f (q_{2k})=q_{2k+1};f (q_{2k+1})=q_{2k}$ and $f (x)=- 1/x$ otherwise.

Or if $x = a_ia_{i-1}....a_0.b_1b_2....$ be the decimal let f:R to R, map to the decimal of all the digits,except the leading digit if it is 5, gets mapped to the digit plus 5 modulo 10. (Example: $f (\pi)=8.6960437108....)$ and $f (52 \frac 18)=57\frac {1,207}{1,800}$)

I got a million of them.

An injection from a set to itself is trivially surjective. No, It is only true for finite sets:

\begin{align}f:&\mathbb N \rightarrow \mathbb N \\ &n \mapsto2n\end{align} is trivially injective and not surjective

So you must also prove that your application is surjective. But it is equally simple: $\forall x \in X, y = f(x) \space\mathrm{verifies}\space f(y) = f(f(x)) = x$