Injective and surjective functions

So I am trying grasp the concepts of injective and surjective functions.

Definitions:

Injective – f: X->Y is injective if for every y in Y there is at most one pre-image x in X such that y = f(x)

Other ways to look at it:

if f(a) != f(b) then a != b

Or, if f(a) = f(b) then a = b – so try to show that f(a) = f(b) means a = b, or to disprove find an example where f(a) = f(b) but a != b

Or think about a graph, there is nowhere you can draw a horizontal line where it intersects the graph more than once

Surjective – f:X->Y is surjective if for every y in Y there is at least one pre-image x in X such that f(x) = y

Other ways to look at it:

To show surjectivity then for each y in Y we can find an x so f(x) = y. So this means trying to solve f(x) = y in terms of y and then substituting that back in:

e.g. f: R->R f(x) = x^3

So, looking at y = x^3, then x = y^1/3. f(x) = f(y^1/3) = (y^1/3)^3 = y.

To disprove, find a value y which doesn’t have a pre-image x

Another way to look at surjective functions is to think of a graph and see that the graph covers all values for y in the domain