How do you tell whether a function is injective or surjective?
Look first at the domain and the codomain, never at the formula alone. On a diagram, count the arrows received by each element of the codomain: at most one means injective, at least one means surjective, exactly one means bijective. With a formula, start from f of a equals f of b for injectivity, and solve f of x equals y for surjectivity.
Is the squaring function injective?
The question is incomplete as it stands. From the reals to the reals, squaring is neither injective nor surjective. From the nonnegative reals to the reals, it becomes injective. From the reals to the nonnegative reals, it becomes surjective. From the nonnegative reals to the nonnegative reals, it is bijective, and its inverse is the square root. One rule, four natures.
What is the difference between injective and surjective?
Both are about the codomain, but not about the same thing. Injective forbids receiving two arrows: two distinct elements of the domain cannot have the same image. Surjective forbids receiving none: every element of the codomain must have at least one preimage. A function can have one without the other, both, or neither.
Does every function have an inverse?
No. Only a bijective function has an inverse function. A hash function, for example, collapses several keys onto the same slot: you cannot go back from the slot to the key, and that is why a hash table must store the key itself. The inverse image of a subset, on the other hand, can be computed for any function and returns a set, sometimes empty.
How do you prove that a function is bijective?
Two routes. The first does the two separate proofs, injectivity then surjectivity, and concludes. The second builds the inverse directly by solving f of x equals y, then checks both compositions: the inverse of f composed with f gives the identity, and f composed with the inverse does too. The second route is faster as soon as the equation can be solved.
Is a bijection between two infinite sets possible?
Yes, and it is even the definition of equal cardinality for infinite sets. The natural numbers are in bijection with the integers, by listing them as zero, minus one, one, minus two, two, and so on. An infinite set can also be in bijection with one of its proper subsets, which is impossible for finite sets.