Shoud a function be defined for all elements in the domain in order to be surjective/bijective? In other words, the surjection says: for any y in the codomain there should exist x in the domain. Now, do I need for every x in the domain to have an y in the codomain for surjectivity?
 A: You need every $x$ in the domain to have a $y$ in the codomain because it's a function, and that's the definition of a function. It had nothing to do with being injective or surjective.
A: A function's surjectivity has got nothing to do with its domain and everything to do with its codomain.
If every element in its codomain Y is an image of one or more elements from its domain X, then the function is surjective.
Mathematically,
$\forall y \in Y, \exists x \in X \ \text{such that}\ y=f(x)$
A: Consider these 4 properties of a mathematical relation:

*

*Is every element in the Domain related to at least one element in the Co-Domain? (The "Defined for all Domain" property)

*For the elements in the Domain that are related to an element in the Co-Domain, are they related to only one element? (Well Defined)

*For the elements in the Co-Domain that are related to, is there only one element in the Domain that relates to them? (Injective)

*Do all of the elements in the Co-Domain have elements in the Domain related to them? (Surjective)

These are actually the same properties, but with the "arrows" pointing the opposite directions.
The if the entire Domain doesn't participate in the relation, then it isn't "Defined", and not a function. If the entire Co-Domain isn't involved, it isn't Surjective.
If it isn't uniquely defined on the Domain, it isn't Well-Defined. If an element in the Co-Domain has many elements mapped to it, it isn't Injective.
If the sets have equal cardinality, then not being defined on the whole Domain means it can't be surjective, and if it isn't well-defined, then it can't be injective.
Soooo....
If the inverse function isn't defined for all elements, then it because the original function wasn't surjuctive, and if the inverse function isn't well defined, it is because the original function wasn't injective.
To be a Bijection, a relation must have all 4 properties.
Cool, huh?
