Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering whether this following is a good proof:


Suppose that $f$ and $g$ are continuous functions and that for all $x$ we have $f(x)^2 = g(x)^2$. Suppose also that $f(x) \ne 0$ for all $x$. Prove that either $f(x) = g(x)$ or $f(x) = -g(x)$ for all $x$.


Suppose that we have $f(x)^2 = g(x)^2$, $f(x) \ne g(x)$ and $f(x) \ne -g(x)$. Then we see that

$$ f(x) \ne g(x) \wedge f(x) \ne -g(x) $$ so (remembering that $f(x) \ne 0$ for all $x$) $$ f(x)^2 = f(x)f(x) \ne g(x) g(x) = (-g(x))(-g(x)) = g(x)^2$$

This is a contradiction, which proves the assertion.

share|cite|improve this question
Not really. You seem to be thinking of it pointwise, while you should be thinking function-wise (i.e., you need to prove that either $f(x) = g(x)$ for all $x$, or $f(x) = -g(x)$ for all $x$). Among other things, you haven't used the continuity of $f$ and $g$, which are important. – Jonathan Christensen Dec 4 '12 at 3:26
@JonathanChristensen But does this not hold for every point $x$? – providence Dec 4 '12 at 3:30
@providence It does, but it doesn't prove the result you want. It could be that on all the rationals, $g(x) = f(x)$, but on all the irrationals, $g(x) = -f(x)$. – Jonathan Christensen Dec 4 '12 at 3:33
@Stuart: Your example violates the condition that $f$ be nowhere $0$. – Brian M. Scott Dec 4 '12 at 3:33
The domain of $f$ and $g$ should be stated. Presumably both are defined and continuous on the entire real line? Connectedness of the domain suffices. – Jonas Meyer Dec 4 '12 at 3:36
up vote 2 down vote accepted

You should be immediately suspicious of your argument, because it doesn’t use the continuity of $f$ and $g$. What if $f(x)=1$ for all $x\in\Bbb R$, and $$g(x)=\begin{cases}-1,&\text{if }x<0\\1,&\text{if }x\ge 0\;?\end{cases}$$

Then $f^2=g^2$, but $f$ is neither $g$ nor $-g$. Of course it’s also true that $g$ is not continuous, but you didn’t use continuity in your argument, so if your argument were correct, this example couldn’t exist.

The real point of the exercise is to show that if $f$ and $g$ are continuous, you can’t have an example like this in which $f(x)=g(x)$ at some points $x$ and $f(x)=-g(x)$ at other points $x$.

HINT: If $f$ is continuous and never $0$, then by the intermediate value theorem either $f$ is strictly positive, or $f$ is strictly negative.

share|cite|improve this answer
Ah, yes I see now. Thank you for your help. I just had this question on an exam and I knew there was something wrong with my answer. Hopefully I will at least get a partial mark. – providence Dec 4 '12 at 3:36
@providence: You’re welcome. – Brian M. Scott Dec 4 '12 at 3:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.