# Show a continuous function with $f(x)=y$ and $f(y)=x$ has a fixed point.

Suppose $$a and $$f:[a,b] \to [a,b]$$ be continous. Suppose that $$x \neq y$$ in $$[a,b]$$ with $$f(x)=y$$ and $$f(y)=x$$. Prove that $$f$$ has a fixed point in $$(x,y)$$.

So I was thinking of considering the function $$g(x)=f(x)-x$$, which we know is continuous. Then we also know that because $$f(a) \geq a$$ that $$g(a)=f(a)-a \geq 0$$. Similarly, because $$f(b) \leq b$$ then $$g(b)=f(b)-b \leq 0$$.

Can we just use the fact that because $$g(x)$$ is continuous, $$0 \in [g(b),g(a)]$$, the IVT says there exists $$c \in [a,b]$$ such that $$g(c)=f(c)-c=0$$ so $$f(c)=c$$? Then we know $$c$$ is a fixed point.

How do we show that $$c$$ is in $$(x,y)$$??

We know that $$g(x)=f(x)-x=y-x \neq 0$$ and $$g(y)=f(y)-y=x-y \neq 0$$ but we don't know that those are in $$(a,b)$$?

You've essentially stated the argument. But, rather restrict $$f$$ to $$[x,y]$$ (where w.l.o.g $$x). Then, define $$g:[x,y]\to\mathbb R$$ by

$$g(t)=f(t)-t$$

for any $$t\in [x,y]$$. As $$f$$ is continuous on $$[a,b]$$ and $$[x,y]\subseteq [a,b]$$, $$g$$ is continuous on $$[x,y]$$. Also, you have $$g(x)=f(x)-x=y-x>0$$ and $$g(y)=f(y)-y=x-y<0$$ as $$x.

Thus, by the intermediate value theorem, there is a $$s\in (x,y)$$ such that $$g(s)=0$$, i.e. $$f(s)=s$$.

Without loss of generality you can assume that $$x < y$$. Now consider $$g(t) = f(t) - t$$ not on the entire interval $$[a, b]$$ but only on $$[x, y]$$.

Then $$g(x) = y- x$$ and $$g(y) = x-y$$ have opposite sign, so that you can apply the intermediate value theorem.

Note also that I have chosen a different variable name ($$t$$ instead of $$x$$) for defining $$g$$, in order to avoid confusion between that variable and the given (fixed) value $$x$$.