Product of functions is $0$ but none of the functions is identically $0$?

Let $f(x)$ be any function whose range is $\{0,1\}$, and let $g(x) = 1 - f(x)$.

For example, let $f$ be such that $f(0) = 1$ and $f(x) = 0$ for all $x \ne 0$.


One continuous example: $f(x)=|x|+x, g(x)=|x|-x$.

For any $x$, at least one of the functions must be $0$, but there is nothing stopping them from "sharing" the $x$-axis between them.


Rather than “piecewise” functions, this has to do with functions which are not analytic.

If $f$ and $g$ are analytic in a neighborhood $U$ of $x_0$, which means that their Taylor series at $x_0$ exist and converge to the functions in a neighborhood of $x_0$, then from $f(x)g(x)=0$ for $x\in U$, then either $f(x)=0$ for every $x\in U$ or $g(x)=0$ for every $x\in U$.

This is easy to prove in the context of holomorphic complex functions: if the set of zeros of a function which is holomorphic in an open connected set has an accumulation point, then the function is identically zero.

Thus all counterexamples to the assertion must not be analytic and the easiest way to produce nonanalytic functions is by using “piecewise definitions”.

A $C^{\infty}$ example: $$ f(x)=\begin{cases} 0 & x\le 0 \\ e^{-1/x^2} & x>0 \end{cases} \qquad g(x)=\begin{cases} e^{-1/x^2} & x<0 \\ 0 & x\ge 0 \end{cases} $$ The function $$ F(x)=\begin{cases} e^{-1/x^2} & x\ne0 \\ 0 & x=0 \end{cases} $$ is the prime example of a $C^{\infty}$ function which is not the sum of its Taylor series at $0$ (all derivatives at $0$ are $0$).

Of course, if you don't care about differentiability, simpler examples can be found: $$ f(x)=x+|x|\qquad g(x)=x-|x| $$ needs no "piecewise definition”.