# Prove that if $f^2=g^2$ and $f(x)$ not zero then $f(x)=g(x)$ or $f(x)=-g(x)$

Suppose that $f$ and $g$ are continuous function on $R$ such that $f^2=g^2$ and $f(x)$ not zero. Show that it's either $f(x)=g(x)$ or $f(x)=-g(x)$

I tried to apply the definition of continuous function to $f$ and $g$, but I don't know how to show $f(x)=g(x)$ or $f(x)=-g(x)$ from $f^2=g^2$. I can't just take square root on both sides.

• Consider $f(x)^2 - g(x)^2 = \bigl(f(x)-g(x)\bigr)\bigl(f(x)+g(x)\bigr) \equiv 0$. At each point, one of the factors must be $0$. Use the continuity to show that it must be the same factor in all points. Nov 15, 2013 at 15:04
• What do you mean by saying "Use the continuity to show that it must be the same factor in all points. "? Can you make it a little bit clearer Nov 15, 2013 at 16:17
• Take $f(x)=|x|$ and $g(x)=x$. Clearly $f$ and $g$ are continuous and $\left(f(x)\right)^2=\left(g(x)\right)^2~~\forall x\in\mathbb{R}$ but $f\not=g$ and $f\not=-g$. Nov 15, 2013 at 22:12
• @meta But $f$ is never zero... Nov 16, 2013 at 13:28
• Ok I missed that point. Nov 16, 2013 at 16:15

HINT: The only problem is going from plus to minus.

I fear that you, and, moreover the question, are mixing up $f(x)$ the function with $f(x)$ the real number.

To answer it properly we will rephrase the questions slightly differently.

Suppose that $f$ and $g$ are continuous functions such that $f^2=g^2$, $f(x)\neq 0$ for any $x\in\mathbb{R}$. Then show that $g=f$ or $g=-f$.

First we show that continuity is necessary for the result to hold.

Consider $f$ defined by

$$f(x):=\left\{\begin{array}{cc}1&\text{ if }x\geq 0\\ -1&\text{ if }x<0\end{array}\right.$$

Now consider $g$ defined by $g(x)=1$. Now $g^2=f^2$ because $g(x)^2=f(x)^2$ for all $x\in\mathbb{R}$ but the function $g$ is neither equal to the function $+f$ nor $-f$; although for every $x$, $g(x)=\pm f(x)$.

Now this is where continuity comes in. Suppose that $f$ is positive and negative at say $x_+$ and $x_-$. By the Intermediate Value Theorem, $f$ has a root between $x_+$ and $x_-$. But by assumption $f(x)\neq 0$. Therefore $f$, and similarly $g$, are always positive or always negative.

We know that $f^2=g^2$ so there is some point $x_0$ where $f(x_0)=+g(x_0)$ or $f(x_0)=-g(x_0)$. In the first case $f$ and $g$ have the same sign while in the second they differ...

Can you finish it off?

• @CameronBuie See edit above. Nov 15, 2013 at 21:30
• @JpMcCarthy Can I conclude that $g=f or g=−f$ from what you have shown, because I see everything has been proven already. Nov 16, 2013 at 13:47
• If it is proof writing you have a little bit to say yet. Nov 17, 2013 at 9:25

Two functions are equal iff they have the same domain, codomain and the same value at each point of the domain. So if $f^2=g^2$ it means that $f^2-g^2=0$ (the zero function).