Is a continuous function plus a discontinuous function discontinuous?

First of all, we should note that $\sin(1/x)$, as it stands is continuous wherever it is defined. By that, I mean that $\sin(1/x)$ is not defined for $x=0$, so we have to assume that $x\neq 0$ when evaluating $\sin(1/x)$. Frequently, we avoid this problem by writing $$g(x)=\begin{cases} \sin(1/x) & x\neq 0\\ 0 & x=0.\end{cases}$$ This is probably the function you mean to use, or at least something like that. As you note, $g(x)$ is discontinuous at $0$. Suppose that $g(x)+x=f(x)$ was continuous. Then $g(x)=f(x)-x$. Since the difference of continuous functions is continuous, $g(x)$ is continuous. But this is a contradiction. Therefore, $g(x)+x$ cannot be continuous.


If $f$ is continuous and $h$ is continuous then $g=h -f$ is continuous.

So if $f$ is continuous and $g$ is discontinuous $f+g = h$ can not be continuous else $h-f =g$ would also be continuous.


Recall the definition of continuous. We say a function is continuous at $x_0$, if $f(x_0)$ is well defined, and $\lim\limits_{x\rightarrow x_0}f(x)$ exists, where $\lim\limits_{x\rightarrow x_0}f(x)=f(x_0)$.

We should always define function formally. Let $f:\mathbb{R}-\{0\}\rightarrow \mathbb{R}$ such that $f(x)=\sin(1/x)$. When we defined $f$ in this way, we have $f$ is a continuous function. Let $g:\mathbb{R}\rightarrow\mathbb{R}$ such that $g(x)=x$. We have this function is continuous. We cannot simply add $f$ and $g$, since their domain is different. We could restrict the domain of $g$ to the set $\mathbb{R}-\{0\}$. Where $g|_{\mathbb{R}-\{0\}}+f$ is continuous.

But in general, for any function $g,f:D\rightarrow R$, where $f$ is continuous and $g$ is discontinuous, we have $f+g$ is discontinuous.