TITLE: $f:\mathbb{R}\to\mathbb{R}$, continuous, such that $xf(x)>0$ when $x\neq 0$. Show that $f(0)=0$
QUESTION [6 upvotes]: I need to prove:
$f:\mathbb{R}\to\mathbb{R}$, continuous, such that $xf(x)>0$ when $x\neq 0$. Show that $f(0)=0$. Show that if we remove the continuity this result will fail. Give an example.
For an example, I thought of $f(x) = x$. This is functinuous, and $xf(x) = x^2>0$ when $x\neq 0$, but I can't make a non continuous version of this function to try. Maybe $f(x) = \frac{x^2-2x}{x-2}$? This functions is not continuous at $x=0$ but it's equal to $x$ everywhere except at $x=0$, so $xf(x)>0$ stills valid, but instead of having $f(0)\neq 0$ we don't even have a definition for $x=0$. Maybe if I define it with any number for $x=0$ it works?
Also, how to prove such result?
I tried considering:
$$g(x) = f(x)-x$$
Somehow if I assume $xf(x)>0$ I need to prove $g(0) = 0$, maybe using the intermediate value theorem. Any ideas? I can't see how $xf(x)>0$ helps.

REPLY [4 votes]: $xf(x) > 0$ implies that $f(x) > 0$ when $x$ is positive and $f(x) < 0$ when $x$ is negative.
By intermediate value theorem, we must have $f(c) = 0$ at some value between a negative and positive number, since we know it is non-zero everywhere else it must occur at zero.