# Give an example of a function $h$ that is discontinuous at every point of $[0,1]$, but with $|h|$ continuous on $[0,1]$

Give an example of a function $h:[0,1]\to\mathbb{R}$ that is discontinuous at every point of $[0,1]$, but such that the function $| h |$ that is continuous on $[0,1]$.

I don't really even know where to start with this one. I would have to prove that the function $| h |$ is continuous on $[0,1]$, ie if we're given any $\varepsilon>0$, there exists $\delta>0$ such that if $x$ and $c$ are any two points in $[0,1]$ with $|x-c| < \delta$, then $|f(x) - f(c)| < \varepsilon$. Alternatively I could use the limit definition. But I can only think of functions that are discontinuous at some points in $[0,1]$ rather than all... I feel like I'm missing something obvious here, but any help is greatly appreciated. This is a question on a past final.

• Try considering characteristic functions. In particular, you might look at the characteristic functions of the rationals and the irrationals. – Josh Keneda Apr 18 '13 at 18:20
• Sorry I should have been more clear about what my course, Introduction to Real Analysis, has covered. So far its been real numbers (ie algebraic and order properties, sup/inf), sequences and series (eg monotone sequences, the Cauchy Criterion, properly divergent sequences), limits, and continuous functions (definition, combinations of continuous functions, and boundedness theorem). Uniform continuity, continuity and gauges, and monotone and inverse functions have not been covered. – Christian Apr 18 '13 at 18:47
• Also, while I understand what an indicator function is (google) its not included in the course so I assume that isn't the type of answer the question is looking for. – Christian Apr 18 '13 at 18:47
• Christian, even if you have not covered indicator functions in the course, the intent of the question may very well be to get you to invent them independently. This question appears in the first half of Richardson's text on advanced calc, and I've done home study through that book and came across this question. I could not figure it out at all and when I looked at the professor's answer, it was an indicator function, which was new to me and not in Richardson's book. Since then, I have looked but not been able to find good answers that don't use an indicator function. – Todd Wilcox Apr 18 '13 at 19:24

You can reverse engineer an example. You want $|f|$ to be continuous, so what is the simplest example of a continuous function? Of course it the constantly $0$ function. So, let's assume $|f(x)|=0$. But then, what can $f(x)$ possibly be? It has to be that $f(x)=0$ as well, which is a continuous function. So this does not work. Ok, then taking $|f(x)|=0$ was too hopeful. Let's try another example of a very simple continuous function, let's assume $|f(x)|=1$ for all $x\in [0,1]$. Now, for any given $x\in [0,1]$, what can $f(x)$ be? Now there are two possibilities: $f(x)=\pm 1$. Good, we have some freedom to play with the values of $f$. Now, playing with just the two values $\pm 1$, how do we make sure $f$ will not be continuous at any point? Well, we need to alternate like crazy between these two values. So we want to say something like $f(x)=1$ if $x$ is of type I, and $f(x)=-1$ if $x$ is not of type I, and such that points of type I are dense and points of type not I are also dense. Of course the rationals $\mathbb Q\cap [0,1]$ are dense and the irrationals $[0,1]-\mathbb Q$ are dense, so that will do the trick.

I would start with a function which I know is discontinuous at every point in $[0, 1]$. The standard one is

$$f(x) = \begin{cases} 1 & x \in \mathbb{Q}\cap[0, 1]\\ 0 & x \notin \mathbb{Q}\cap[0, 1] \end{cases}$$

which is the indicator function of the set $\mathbb{Q}\cap[0, 1]$. See if you can somehow adjust it for your purpose.

• Please provide justification that $|h(x)|$ is continuous on [0,1] – user1942348 Feb 25 '17 at 17:39
• @user1942348: I haven't given an $h$, I have only given an indication of how to construct such an $h$. – Michael Albanese Feb 25 '17 at 17:51
• That's fine. Your example motivates me. I would be grateful if you kindly post an answer for h as asked in the question. I am unable to construct it. – user1942348 Feb 25 '17 at 17:54
• @user1942348: I would rather not do that. Here is a further hint though, it is enough to change the value of the function on the irrational numbers (i.e. change the zero to a different number). – Michael Albanese Feb 25 '17 at 18:15
• $f(x) = \begin{cases} 1 & x \in \mathbb{Q}\cap[0, 1]\\ -1 & x \notin \mathbb{Q}\cap[0, 1] \end{cases}$ Is this correct? – user1942348 Feb 25 '17 at 18:21