Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Which function ($f$) is continuous nowhere but $|f(x)|$ is continuous everywhere?

I found this question here, the question seems much interesting but for obvious reason it is closed there, I was wondering how to derive such a function?

share|cite|improve this question
you should either put $|x|\to |f|$ or take any discontinuous $f$ as an answer – Ilya Oct 24 '11 at 15:58
You might want to work this out for yourself, so here is a hint: take a non-zero constant function for $|f(x)|$ (which is what I think you must mean, with $f$ mapping real line to real line). Then you need to think of a way of constructing $f(x)$ so that it is discontinuous - how could you make it discontinuous at a point? How could you use that on enough points to make it discontinuous everywhere? – Mark Bennet Oct 24 '11 at 16:00
up vote 18 down vote accepted

You could take $$f(x)=\begin{cases}1&x\in \mathbb Q \\ -1&x\in\mathbb R\setminus\mathbb Q\end{cases}$$

share|cite|improve this answer
Could you explain how? – Quixotic Oct 24 '11 at 15:59
I assume you meant that $x\mapsto|f(x)|$ should be continuous everywhere. That is true here because $|f(x)|=1$ for all $x$. Did you mean something else by "$|x|$ is continuous everywhere"? – Henning Makholm Oct 24 '11 at 16:01
Also known as $f=2\cdot\chi_{\Bbb Q}-1,$ for those familiar with characteristic/indicator functions. – Cameron Buie Dec 17 '13 at 0:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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