I was reading a Mathematics books and it gave the axiomatic definition of a function as being a mapping from a set called "The domaine of the function" to another set called "The codomaine of the function", and at first I thought the codomaine is the image of the domaine by the function (i.e. the set that contains and only contains the images of every element of the domaine). Turns out that's the range or image of the domaine which is only a subset of the codomaine and is equal to the codomaine only if the function is surjective.
My question is : Why not define a function as a mapping from a domaine (the set A) to the set B (defined as the set containing and only containing the image of every element of the domaine)? Why the need for the Codomaine set with extra elements? Isn't the complement of the range in the Codomaine irrelevant to the function? In other words, aren't all functions surjective in the end?
Sometimes they say that the codomaine is the set of possible outcomes of a function, but I don't understand what they mean by "possible" in this context.