[Math] $f(x)$ not continous at 0 but $f(x) + \frac{1}{f(x)}$ continuous at 0: Is the example valid

continuityfunctionsreal-analysis

I'm but a lowly electrical engineering student interested in mathematics. Recently, I've been working through the second edition of Stephen Abbott's Understanding Analysis and I encountered a problem that I'm not entirely sure about, specifically problem 4.3.6, part d, which states:

Provide an example or explain why the request is impossible: A function $f(x)$ which is not continuous at 0 such that $f(x) + \frac{1}{f(x)}$ is continuous at 0.

Now, being supremely lazy, my instinct at first was to say, "sure, consider the function $f:\mathbb{R} \to \mathbb{R}$ defined by
$$f(x) =
\begin{cases}
1, & \text{if $x=0$} \\
0, & \text{if $x \neq 0$}
\end{cases}"$$
Then, my reasoning was that the only way we can define $g(x) = f(x) + \frac{1}{f(x)}$ is via the restriction of $f$ onto the domain $\{0\}$. So, since 0 is clearly an isolated point in the domain of $g$, it follows that $g(x)$ must be continuous at 0.

Does this answer fit the "spirit" of the question? Or am I only allowed to choose an $f$ such that $g$ can have the same domain as $f$? Thanks for your help!

Best Answer

Let $f$ be given by

$$f(x)=\begin{cases}C&,x>0\\\\\frac1C&,x\le0\end{cases}$$

where $C\ne1$, $C\ne 0$.