injective, surjective and bijective functions
A function is a rule that takes each input to exactly one output — like a vending machine where pressing a button always gives one specific item. Three adjectives describe how a function lines its inputs up with its outputs. Injective ('one-to-one') means no two different inputs share an output; surjective ('onto') means every possible output actually gets used; bijective means both at once — a flawless pairing with nothing doubled up and nothing left over.
Some vocabulary first: a function f from A to B (written f : A → B) has domain A (the allowed inputs), codomain B (where outputs are allowed to land), and image (the outputs that actually occur). Now: f is injective if f(x) = f(y) forces x = y (distinct inputs give distinct outputs); f is surjective if for every b in B there is some a with f(a) = b (the image fills the whole codomain); f is bijective if it is both, which means it pairs A and B up perfectly and can be run backwards as an inverse. Doubling a number, x to 2x, is injective (different inputs, different doubles) but not surjective onto the integers (no integer doubles to 3). Sorting people into 'older than 18 or not' is surjective onto {yes, no} but wildly non-injective.
Bijections are the backbone of counting and of comparing the sizes of sets, even infinite ones: two sets have the same size exactly when a bijection exists between them. That single idea, pushed to infinite sets, is what later separates the countable from the uncountable and powers Cantor's diagonal argument. Injections also matter directly: a sensible encoding of machines as strings must be injective so that no two different machines get the same code and decoding stays unambiguous.
f(n) = n + 1 on the integers is bijective: every integer is hit (surjective) and no two inputs collide (injective), so it has an inverse, subtract 1. But g(n) = n^2 on the integers is neither — g(2) = g(−2) = 4 breaks injectivity, and 3 is never an output, breaking surjectivity.
Adding 1 is a bijection (and invertible); squaring is neither injective nor surjective on the integers.
Surjectivity depends on the chosen codomain: doubling, x to 2x, is surjective onto the even integers but not onto all integers. Always state the codomain before calling a function 'onto'.