Assume $f(x)$ is such that $f'(x)>0$, $s(x)$ only takes two values $1$, $-1$ on $R$. If $g(x)=s(x)f(x)$ is differentiable, can one show $s$ constant? Assume that $f(x): x\in \mathbb{R}$ differentiable, such that $f'(x)\neq 0$ for every point $x$ such that $f(x) = 0$, and $s(x)$ only takes two values $1$ and $-1$ on $\mathbb{R}$. If $g(x)=s(x)f(x)$ is differentiable, can one show that $s(x)$ is constant on $\mathbb{R}$?
This question arises from a former question of mine.
edit: I now think the appropriate statement of the original problem is as follows:
Assume that $f(x): x\in \mathbb{R}$ differentiable, such that $f'(x)\neq 0$ for every point $x$ such that $f(x) = 0$, and $s(x)$ only takes two values $1$ and $-1$ on $\mathbb{R}$. If $g(x)=s(x)f(x)$ is differentiable, then $s(x)$ is continuous on $\mathbb{R}$ outside a set of removable discontinuous points $S$, where $S$ is a subset of zeros of $f(x)$.
Both QC_QAOA's answer and mine actually establish the above fact. To provide an example contradicting the original statement: $f(x)=x$, $s(x)$ takes $1$ for all $x \in \mathbb{R}$ but $-1$ for $x=0$. Then $x=0$ is a removable discontinuous point of $s$, and it doesn't sabotage the fact that $s(x)g(x)$ is still differentiable.
 A: Obviously, we do not care about any points where $s(x)$ is continuous.
Assume the following:
$1)$ $s(x)$ is discontinuous
$2)$ $g(x)=s(x)f(x)$ is differentiable
$3)$ Either $f(x_0)\neq 0$ or $f'(x_0)\neq 0$
Now, consider the set $S$ of discontinuities of $s(x)$. By assumption, this set is non-empty. There are two possibilities: $S$ has at least one isolated point and $S$ has no isolated points

Case 1: Suppose that $S$ has an isolated point $x_0$. Let $h_n$ be any sequence approaching $0$ from above. Clearly, either
$$s(x_0+h_n)\neq s(x_0)\text{ and }s(x_0-h_n)= s(x_0)$$
or
$$s(x_0+h_n)= s(x_0)\text{ and }s(x_0-h_n)\neq s(x_0)$$
Suppose it is the former (the latter case is argued identically). Then this gives us
$$g'(x_0)=\lim_{n\to \infty}\frac{s(x_0+h_n)f(x_0+h_n)-s(x_0)f(x_0)}{h_n}$$
which exists by assumption. But $s(x_0+h_n)$ and $s(x_0)$ have opposite sign. Thus, this is equal to
$$=-s(x_0)\lim_{n\to\infty }\frac{f(x_0+h_n)+f(x_0)}{h_n}$$
Since $f(x)$ is continuous, this quantity can only exist if $f(x_0)=0$. But then
$$=-s(x_0)\lim_{n\to\infty }\frac{f(x_0+h_n)+f(x_0)}{h_n}=-s(x_0)\lim_{n\to\infty }\frac{f(x_0+h_n)+f(x_0)-2f(x_0)}{h_n}$$
$$=-s(x_0)\lim_{n\to\infty }\frac{f(x_0+h_n)-f(x_0)}{h_n}=-s(x_0)f'(x_0)$$
However, in the same vein we have
$$g'(x_0)=\lim_{n\to \infty}\frac{s(x_0)f(x_0)-s(x_0-h_n)f(x_0-h_n)}{h_n}$$
$$=-s(x_0)\lim_{n\to \infty}\frac{f(x_0-h_n)}{h_n}=-s(x_0)[-f'(x_0)]=s(x_0)f(x_0)$$
Taken together, this implies that
$$-s(x_0)f'(x_0)=s(x_0)f'(x_0)\Rightarrow f'(x_0)=0$$
Since $f(x_0)=0$, this contradicts assumption $3$.

Case 2: Suppose that every point in $S$ is non-isolated. Let $x_0$ be an arbitrary point in $S$ and construct two sequences
$1)$ Let $a_n>0$ approach $0$ and $s(x_0+a_n)\neq s(x_0)$
$2)$ Let $b_n>0$ approach $0$ and $s(x_0+b_n)=s(x_0)$
We are assured that such sequences exist since $x_0$ is not isolated in $S$. Using the same arguement as Case $1$, we can find that $f(x_0)=0$. This then implies
$$g'(x_0)=\lim_{n\to \infty}\frac{s(x_0+a_n)f(x_0+a_n)-s(x_0)f(x_0)}{a_n}$$
$$=-s(x_0)\lim_{n\to \infty}\frac{f(x_0+a_n)-f(x_0)}{a_n}=-s(x_0)f'(x_0)$$
With $b_n$ we get
$$g'(x_0)=\lim_{n\to \infty}\frac{s(x_0+b_n)f(x_0+b_n)-s(x_0)f(x_0)}{b_n}$$
$$=s(x_0)\lim_{n\to \infty}\frac{f(x_0+b_n)-f(x_0)}{b_n}=s(x_0)f'(x_0)$$
Again, this leads to the contradiction that $f'(x_0)=0$.
A: Proof:
Given the obvious continuity of $s(x)=g(x)/f(x)$ on nonzeros of $f(x)$, we need only to prove continuity of $s(x)$ on point $x$ such that $f(x)=0$.
Choose any $x_0$ satisfying $f(x_0)=0$. Given the assumptions, $f'(x_0)\gt 0$ or $\lt 0$. WLOG we assume $f'(x_0)\gt 0$. In this case, we know for some $r\gt 0$, $\frac{f(x)-f(x_0)}{x-x_0} \gt 0$ for all $x\in (x_0,x_0+r]$. It follows that $f(x) \gt f(x_0) = 0$ whenever $x\in (x_0,x_0+r]$. Following a similar argument $f(x) \lt f(x_0) = 0$ whenever $x\in [x_0-r,x_0)$.
Next we show $s(x)$ is constant respectively on $(x_0,x_0+r]$ and $[x_0-r,x_0)$. Otherwise, suppose $s(x_1) = -1$ and $s(x_2) = 1$ for some $x_1,x_2\in (x_0,x_0+r]$. Then given the continuity of $s(x)$ on $(x_0, x_0+r)$ there must be some $x_3 \in (x_1,x_2)$ with $s(x_3)=0$, a contradiction. The consistency of $s(x)$ on $[x_0-r,x_0)$ follows from a similar argument.
Now we claim that $s(x)$ must take the same value on both $(x_0,x_0+r]$ and $[x_0-r,x_0)$. Otherwise, if $s(x)$ takes $1$ on the first inteval and $-1$ on the second, then we must have $$g_{+}'(x_0) = \lim_{x \to x_0^+} \frac{g(x)-g(x_0)}{x-x_0} =  \lim_{x \to x_0^+} \frac{f(x)-f(x_0)}{x-x_0} = f'(x_0)$$ and $$g_{-}'(x_0) = \lim_{x \to x_0^-} \frac{g(x)-g(x_0)}{x-x_0} = \lim_{x \to x_0^-} \frac{-f(x)+f(x_0)}{x-x_0} = -f'(x_0).$$ Since $f'(x_0)$ is assumed to be nonzero, we know  $g_+'(x_0) \neq g_-'(x_0)$, contradicting the differentiability of $g(x)$ on $x_0$. A similar method establishes the case where $s(x)$ takes $-1$ on the first inteval and $1$ on the second. We have completed the proof.
