Example of a function $f$ which is differentiable at $a$, but $f^{-1}$ is discontinuous at $f(a)$ Let $A$ be an open set of $\mathbb R$. Is there a function $f:A\to\mathbb R$ with the following properties:

*

*$f$ is one-to-one,

*There is an $a\in A$ such that $f$ is differentiable at $a$,

*$f'(a)\neq0$,

*But $f^{-1}$ is discontinuous at $f(a)$?


This is a follow-up question to the following: Does the inverse function theorem require continuity as a hypothesis? In this question, I asked whether the following conditions were sufficient to conclude that $f^{-1}$ is differentiable at $f(a)$:

*

*$f$ is one-to-one,

*$f$ is differentiable at $a\in A$,

*$f'(a)\neq0$.

In a comment, Hans Lundmark wrote that these conditions were not sufficient; however, if we additionally assume that $f^{-1}$ is continuous at $f(a)$, then the theorem holds.
 A: Consider the following simple method to construct a function $f\colon\mathbb{R}\to\mathbb{R}$ that is continuous at $a$ but that cannot have an inverse that is continuous at $f(a)$.
Start with any continuous function $g\colon\mathbb{R}\to\mathbb{R}$. Take two injective sequences $x_n\to a$ and $y_n\not\to a$ and move around function values on these two sequences, defining a new function
\begin{align}
f(x_n) &:= g(x_{2n}),\\ 
f(y_n) &:= g(x_{2n+1}),\quad\text{and}\\
f(x) &:= g(x)\quad\text{for all other points}
\end{align}
Then all the values $f(x_n)$ remain near $f(a)$, so $f$ is still continuous at $a$. But we also have $f(y_n)\to f(a)$ even though $y_n\not\to a$, so $f^{-1}$ (if it exists) cannot be continuous at $f(a)$.
This construction can be used to build the required example. If $g$ is injective then so is $f$, so the inverse $f^{-1}$ exists and is discontinuous. However even if $g$ is differentiable, the modification $f$ doesn't have to be differentiable, unless the sequence $x_n$ is carefully chosen.
For $g(x)=x$ and $x_n\to 0$, the function $f$ is differentiable at 0 with $f'(0)=1$ exactly when the sequence has the property that $x_{2n}/x_n\to 1$. So for $g(x)=x$, we may take for example $x_n=1/\log n$ to get the required example.
