7

Given $$(f◦g)(x)=x$$ (from R to R for any x in R)

does it mean that also $$(g◦f)(x)=x$$
I feel like its not true but I can't find counter example :( I tried numerous ways for several hours but I cant counter it though I almost know for sure that this will only be true if g is onto but I don't know why :P

The One
  • 1,173

4 Answers4

11

Take, for example, $f(x) = \ln(x)$ and $g(x) = e^x$.

Then, for every $x\in\mathbb R$, you have $f(g(x))=\ln(e^x) = x$. But that is not true the other way around, i.e. the statement:

For every $x\in \mathbb R: g(f(x)) = x$

is a false statement, because $f(x)$ is not defined for $x\leq0$.


If you want $f$ to be defined everywhere, you can define

$$f(x)=\begin{cases}\ln|x| & \text{if } x\neq 0\\ 0&\text{if } x = 0\end{cases}.$$

You then have, for every $x\in\mathbb R$: $f(g(x)) = f(e^x)$ which, because $e^x\neq 0$, is equal to $\ln(|e^x|) = \ln(e^x)=x$.

On the other hand, you have, for every $0\neq x\in \mathbb R$,$g(f(x)) = e^{\ln|x|} = |x|$, so if $x<0$, $g(f(x))$ is not equal to $x$.

5xum
  • 123,496
  • 6
  • 128
  • 204
  • You think that's a counter-example? – Thomas Andrews Dec 12 '14 at 13:46
  • @ThomasAndrews I expanded my answer. It is a counterexample because $f\circ g$ is the identity function on $(0,\infty)$, not on the whole reals. – 5xum Dec 12 '14 at 13:48
  • 1
    It's not stated, but I assumed he meant that $f,g$ are functions from $\mathbb R$ to $\mathbb R$. – Thomas Andrews Dec 12 '14 at 13:50
  • @ThomasAndrews So what if I take $f(x) = \ln|x|$? Then $g(f(x)) = |x|$, it is still not $x$. And even if it was equal to $x$, that does not mean that my example is not a counterexample. – 5xum Dec 12 '14 at 13:50
  • @ThomasAndrews In the second part of my answer, I give an example where $f$ and $g$ are both functions from $\mathbb R$ to $\mathbb R$. – 5xum Dec 12 '14 at 13:54
  • 2
    Can someone please explain the downvote? How is what I have written not a counterexample? – 5xum Dec 12 '14 at 13:54
  • 2
    $f(x) = \ln x$ is not a counterexample since then $f(x)$ is not defined for $x \le 0$. But $f(x) = \ln |x|$ etc. is indeed a counterexample. – Hans Engler Dec 12 '14 at 14:39
  • 1
    @HansEngler Actually, even for $f(x)=\ln (x)$, the statement: "$\forall x\in\mathbb R: (f\circ g)(x) = x$" is true. Nothing OP wrote means that $f$ must be defined on $\mathbb R$. He only says that $f\circ g$ should be. – 5xum Dec 12 '14 at 14:43
  • Actually, this is the best answer. I would give the same or sth similar. – Konstantinos Gaitanas Dec 12 '14 at 14:57
  • Yes $f$ doesn't have to be onto, but if i would have said that g has to be onto, will it now be that (g∘f)(x)=x? – The One Dec 13 '14 at 09:05
  • Do you have a counterexample if $f$ is a continuous function on $\mathbb{R}$? – user1537366 Dec 13 '14 at 11:04
5

Let $ dom(f)$ be the domain of the function $f$ and $im(f)$ be its image. It's easier to understand this if you write the question in the form

"If $(f \circ g)(x) = x$ for all $x \in dom(g)$, then does if follow that $(g \circ f)(y) = y$ for all $y \in dom(f)$?"

To get the general answer, note that $(f \circ g)(x) = f(g(x)) = x$ implies $g(f(g(x))) = g(x)$. Therefore, $(g \circ f)(y) = y$ for all $y$ that can be written as $y = g(x)$ for some $x$, i.e. for all $y \in im(g)$. But if there are $y \in dom(f)$ that are not in $im(g)$, then $g \circ f(y)$ need not equal $y$.

So the answer is yes if $im(g) = dom(f)$, but it may be no if that is not the case.

In the case discussed by @5xum, $g(x) = e^x$ and $im(g) = (0, \infty)$. Now if $f(x) = \ln x$, then $dom(f) = (0,\infty)$. Both $(f\circ g)(x) = x$ and $(g \circ f)(y) = y$ are correct for all $x \in dom(g), y \in dom(f)$. But if $f(x) = \ln |x|, f(0) = 0$, then $dom(f) = \mathbb{R}$ which is larger than $im(g)$. Therefore there are $y \in dom(f)$ such that $(g \circ f)(y) \ne y$ although $(f \circ g)(x) = x$ for all $x \in dom(g)$.

PierreCarre
  • 20,974
  • 1
  • 18
  • 34
Hans Engler
  • 15,439
3

Let $f(x)=\begin{cases}\tan(x),&\text{if }x \in (-\pi/2,\pi/2)\\0,&\text{otherwise}\end{cases}$

and $g(x)=\tan^{-1}(x)$ with image $(-\pi/2,\pi/2)$.

Then $f(g(x))=x$ but $g(f(2\pi))=0\ne 2\pi$.

The hypothesis is indeed true if both $f$ and $g$ are continuous. $g(\mathbb{R})$ is an interval, and $f|_{g(\mathbb{R})}$ has inverse* $g$ and hence is injective, so must be strictly monotone. If $g(\mathbb{R})$ has a finite endpoint, e.g. $(-\infty,t)$, then $\lim_{x\to t^-} f(x)=\pm\infty$, otherwise $f$ cannot have image $\mathbb{R}$. This contradicts the assumption that $f$ is continuous. Hence $g$ is surjective, and so $f$ and $g$ must be inverses of each other.

*To show that $\forall x\in g(\mathbb{R}), g(f(x))=x$:

Let $y\in \mathbb{R}$ s.t. $g(y)=x$.

$g(f(x))=g(f(g(y)))=g(y)=x$.

I think you can come up with a counterexample if we have only $f$ continuous.

user1537366
  • 2,113
3

Define: $$f(x)=\begin{cases} x&\text{ if }x\le0,\\ 0&\text{ if }0\le x\le1,\\ x-1&\text{ if }x\ge1; \end{cases}$$ $$g(x)=\begin{cases} x&\text{ if }\,x\lt0,\\ x+1&\text{ if }\,x\ge0.\\ \end{cases}$$ Then $f$ is continuous, $f(g(x))=x$ for all $x$, and $g(f(0))=1$.

bof
  • 78,265