# How to Prove if Two Functions are Equal

My question is how do you determine if two functions are indeed equal. I know $$f$$ and $$g$$ will be equal if $$f(x) = g(x)$$, but how do you determine that for all $$x$$ values? One could graph to get a good idea, but that still that may only mean they are equal for the $$x$$ values for the portion of the graph seen and not for all $$x$$ values.

So for functions like the ones below, it's particularly easy to determine if they are equal just by looking at them, but how do you PROVE they are equal?

$$f: \Bbb Z \rightarrow \Bbb Z, \text{ where } f(x) = x^2$$

$$g: \Bbb Z \rightarrow \Bbb Z, \text{ where } f(x) = \left |x \right |^2$$

Or, for instance, here is another example:

$$f: \Bbb R \times \Bbb R \rightarrow \Bbb R, \text{ where } f(x,y) = \left | x+y \right |$$

$$g: \Bbb R \times \Bbb R \rightarrow \Bbb R, \text{ where } g(x,y) = \left | x \right | +\left | y \right |$$

Again, how do you prove they are equal?

• The second case is false. $f(1,-1)=0\neq 2=g(1,-1)$. – lulu Feb 10 '20 at 20:11
• The first one is true because you can prove that $x^2=|x|^2$ for all integers $x$. Sometimes it is also enough to look just at the domains. So $f\colon \Bbb N\rightarrow \Bbb N$ with $f(x)=x^2$ is different from $g\colon \Bbb Z\rightarrow \Bbb N$ with $g(x)=x^2$. – Dietrich Burde Feb 10 '20 at 20:11
• For the first case, handle the positive and negative integers separately, and remark that $x^2=(-x)^2$. – lulu Feb 10 '20 at 20:12
• As for general strategies, which seems to be what you are asking for, if they happen to be equal, then show that whatever specific $x$ you take that you can show that $f(x)=g(x)$. This might be easier to do by breaking into cases (like your example by looking at negative $x$ separately than non-negative $x$). For proving that they are not equal, you find an example of an $x$ such that $f(x)\neq g(x)$. This will sometimes be spotted by inspection or intuition, but otherwise you might get a clue as to what might work by having tried to prove that they were equal and hitting a wall. – JMoravitz Feb 10 '20 at 20:14
• Wouldn't it be possible to prove that by induction? – Noctilucente Feb 10 '20 at 20:15

Going on what lulu has said - For the first case, use proof by contradiction and assume that $$\exists k \in \mathbb{Z}$$ such that $$f(k) \neq g(k)$$. Using the definitions of $$f$$ and $$g$$:
$$k^2 \neq |k|^2$$
If the two terms are not equal, then the difference between the two is nonzero, or $$k^2 - |k|^2 \neq 0$$. The expression on the left hand side of the inequality can be factored such that
$$(k - |k|)(k + |k|)$$ must be nonzero. By the definition of absolute value, you will find that this expression can never be nonzero for all $$k \in \mathbb{Z}$$. Thus, by contradiction, $$f(x) = g(x)$$ for all $$x \in \mathbb{Z}$$.