TITLE: What is the practical benefit of a function being injective? surjective?
QUESTION [7 upvotes]: I have learned that an injective function is one such that no two elements of the domain map to the same value in the codomain. 
Example: The function $x \mapsto x^2$ is injective when the domain is positive numbers but is not injective when the domain is all numbers because both $(-2)^2$ and $2^2$ map to the same value, $4$.
Is there an advantage of an injective function over a non-injective function? What is the practical benefit of injective functions? Or perhaps there is an advantage to a function not being injective?
I have also learned about surjective functions: a surjective function is one such that for each element in the codomain there is at least one element in the domain that maps to it.
What is the benefit of a function being surjective? Is there a danger to using functions that are not surjective?
I'd like to have a deeper understanding of injective and surjective than simply be able to parrot back their definitions. Please help.

REPLY [4 votes]: If you are studying algebraic structures (let's say rings) an injective homomorphism $\phi: R \longrightarrow S$ provides you with a way to interpret one ring as a subring of the other.  After all, this just means that $R$ will be isomorphic to $\mathrm{Im}(\phi)$.  For example, let $\phi: \mathbb{Q} \longrightarrow \mathbb{Q}[X]$ be defined by $\phi(a) = a + 0x + 0x^{2} + \cdots$.   One can then check (you check!) that $\phi$ is injective and a homomorphism.  
And indeed, $\mathbb{Q}$ can be interpreted as a subsystem of the ring of polynomials with coefficients in $\mathbb{Q}$, just by viewing each rational as a constant polynomial.