# $f+g$ is continuous and $f$ and $g$ are everywhere discontinuous

I know that if $$f$$ and $$g$$ are both continuous then $$f+g$$ is continuous. I also know that there are discontinuous functions whose sum is continuous. However, I want to find two functions that are everywhere discontinuous, yet their sum is continuous. I can only come up with examples such as $$f(x) = sgn x$$, $$g(x) =-sgn x$$, but these only have one discontinuity point.

• Take $f$ any everywhere discontinuous and $g=-f$. – Wojowu Mar 2 '19 at 14:25
• Try Dirchilet type functions. – Dbchatto67 Mar 2 '19 at 14:26

Take

$$f(x) = \left\{ \begin{array}{ll} 1 & \quad x \in \Bbb Q \\ 0 & \quad x \in \Bbb R \setminus \Bbb Q \end{array} \right.$$

and

$$g(x) = \left\{ \begin{array}{ll} 0 & \quad x \in \Bbb Q \\ 1 & \quad x \in \Bbb R \setminus \Bbb Q \end{array} \right.$$

You only need to find a function $$f$$ that's discontinuous everywhere, since then you can take $$g=-f$$ and clearly $$f+g=0$$ will be continous.

Such a function can be found by taking $$f(x)=1$$ if $$x$$ is a rational number, and $$f(x)=0$$ otherwise.

To generate infinitely many examples, take $$g = h - f$$, where $$h$$ is a continuous function.