# Two functions discontinuous, but sum continuous

I have some exercise that asks me this:

Find $f$ and $g$ discontinuos such that $f+g$ is continuous. This is what I tought:

$$f = \mbox{sign}(x)$$ $$g = -\mbox{sign}(x)$$

Where $\mbox{sign}(x)$ is the function that maps to $1$ if $x\ge0$ and $-1$ if $x<0$. Then, the two are discontinuous in $0$, but the sum, is continuous, because it's equal to $0$ in every point. First of all, is this example correct?

The exercise also asks me to find examples such that:

$f,g$ discontinuous, but $f$ composed with $g$ is continuous. (need help)

$f$ continuous, $g$ discontinuous but the composite $f$ with $g$ is continuous.

(for the second one, if I take $g=\mbox{sign}(x)$ and $f=|x|$, then $fog = 1$. Is this right?

Could you guys give at least a hint, or a less poor example?

• Your examples are simple, but not bad. Simple can be good. – David K May 22 '14 at 3:09

You can come up with some really interesting examples of compositions that end up being continuous where the components are not. Here's my favorite:

$f(x)=\begin{cases} 0 & \text{if }x \text{ is irrational}\\ 1 & \text{if }x \text{ is rational} \end{cases}$

Then $f\circ f$ is the constant function $1$ which is continuous.

Your examples are wonderful, with one correction: your sign function is actually not a function, because $$\operatorname{sign}(0)$$ maps to both $$1$$ and $$-1$$ (in high school algebra parlance, this fails the "vertical line test"). This is easy to correct, however. Just let $$\operatorname{sign}(0)=0$$. An example of discontinuous functions that compose to a continuous function runs thus: let $$f(x)=0$$ if $$x=0$$, and $$f(x)=1$$ otherwise; let $$g(x)=1$$ if $$x=0$$ or $$x=1$$, and $$g(x)=2$$ otherwise. $$f(g(x))$$ is thus continuous, while $$f$$ and $$g$$ are discontinuous.

• It seems this objection has been addressed in the problem statement by defining sign$(0)$ as $1$. – David K May 22 '14 at 2:48

If $f$ is discontinuous and has a discontinuous inverse, then let $g = f^{-1}$, so that $f \circ g$ is the identity function.

As a candidate for such an $f$, I offer $f(x) = 1 + 2 \lfloor x \rfloor - x$. But there are uncountably many such functions.

You can also take $$f(x)=sgnx$$ and $$g(x)=x(1-x^2)$$. Here $$f$$ is discontinuous at $$0$$ and $$g$$ is continuous at $$f(0)$$ but the composite $$gf$$ is continuous at $$0$$.