Proving a function is one to one over a domain and codomain I know that the definition of a one-to-one function is $f(x_{1})=f(x_2) \implies x_1 = x_2$. I am having trouble understanding how to prove that a function is one-to-one.
This was a given example: $f(x)=x^3$
$$f(x_{1})=f(x_2) \implies (x_1)^3 = (x_2)^3$$
$$(x_1)^3 = (x_2)^3 \implies x_1 = x_2$$
therefore $f(x)$ is one-to-one.
What I got from this example is to assume that $f(x_1)=f(x_2)$ then try to simplify the equation in order to obtain $x_1=x_2$.
Now let's say I have a different function $g(x)=x^2$ and $g:\mathbb{R}\to \mathbb{R}$. I know that this function is not one to one but using the same proof method above I get this:
$$g(x_1) = g(x_2) \implies (x_1)^2 = (x_2)^2$$
$$(x_1)^2 = (x_2)^2 \implies x_1 = x_2$$
This means that $g(x)$ is one to one but this is clearly not true. Am I missing something in the proof or am I doing one-to-one proofs completely wrong? What I am currently doing is trying to solve the equation to end up with $x_1 = x_2$.
Another example:
$$f(x)=3x^3-2x$$
$$f(x_1)=f(x_2) \implies (3x_1)^3-2x_1 = (3x_2)^3-2x_2$$
Using the same proof strategy as before I am stuck on this step. How would I continue to conclude whether or not he function is an injection?
 A: Your method of proof is correct, but you're missing a subtle point having to do with exponentiation. Taking the square root of the equation $x_1^2 = x_2^2$ does not give $x_1 = x_2$; instead, it gives $|x_1|=|x_2|$; in other words, $x_1=\pm x_2$. After all, one definition of the absolute value function is $|x|=\sqrt{x^2}$. (Do you see why?)
On the other hand, taking the cube root of the equation $x_1^3=x_2^3$ gives $x_1 = x_2$ because the cube-root function is a genuine inverse to the cubing function (when the quantities involved are real).
A: Your proof strategy is fine. What you need to pay attention to is the following. For real numbers $x,y$ if $x^3=y^3$, then $x=y$  because for every real number $t$ there is a unique number $s$ such that $s^3=t$. However, for almost all real numbers $s$ there are two numbers $s$ with $s^2=t$, and so you can not conclude from $x^2=y^2$ that $x=y$ (e.g., $x=2, y=-2$). 
A rigorous proof of the above is a bit involved, but I'm sure you will convince yourself of their validity by plotting the graphs of the relevant functions. 
By the way, the function $z\mapsto z^3$ is not injective when considered as a function $\mathbb C \to \mathbb C$, so there really is a special property here of the real numbers that makes the function $x\mapsto x^3$ injective. 
