-2
$\begingroup$

So I had an exam today and one of the questions were: Give an example of a function $f$ which is nowhere continuous but $|f|$ should be continuous at all points. At first I had no idea how to do it then I came up with this, even though I know it's wrong:

$$f(x)= \begin {cases} \ \sqrt{x}&\text{if }x <0\\ \sqrt{-x}\ &\text{if }x > 0\\ \end {cases}$$

Like I said I know it's wrong..but can someone give me an example of this? Thanks.

$\endgroup$

marked as duplicate by David Mitra, user1337, Shuchang, Cameron Buie, Eric Naslund Dec 17 '13 at 1:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5
$\begingroup$

Let $$f(x)=\begin{cases}1,&\text{if }x\in\Bbb Q\\-1,&\text{if }x\in\Bbb R\setminus\Bbb Q\;.\end{cases}$$

There are many variations on this, but this is one of the simplest.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.