Guys I need a bit of help from you. I have recently started studying calculus. Today I stumbled upon a question which I am somehow not able to solve. Help is appreciated.
Give an example of a function $f$ such that $f$ is continuous nowhere but $\vert f\vert$ is continuous everywhere.
I have tried checking a lot of functions. but none was fruitful. Upon first glance I thought that $f(x)=\frac {\vert x\vert}{x}$ would work but it is also continuous at some or the other point.
Any help would be appreciated. Thanks
Take a function with some non-zero value on the rationals and exactly minus that on the irrationals.
For example, $f = \mathbf 1_{Q} - \mathbf 1_{\mathbb R \setminus Q}$, where $\mathbf 1_X$ for any $X \subset \mathbb R$ is the indicator function, i.e. $\mathbf 1_X(x)=1$ if $x \in X$ and $0$ otherwise.
Then it won't be continuous anywhere : given $x \in \mathbb R$, pick a sequence $x_{n1}$ of rationals and $x_{n2}$ of irrationals converging to $x$, and note that $f(x_{n1}) \to 1$ while $f(x_{n2}) \to -1$, whatever $f(x)$ is, it can't be both $1$ and $-1$.
But then, $|f| = 1$! So it is obviously continuous.