Types of functions

Given a function f:A→Bf : A \to B, can you tell — just from the rule and the stated domain and codomain — whether every output is hit exactly once, whether every element of BB is hit at all, both, or neither? This is the second big theme of Class 12's Relations and Functions chapter: classifying a function as one-one (injective), onto (surjective), both (a bijection), or neither. You already know what a function is from Class 11; now you learn the precise algebraic tests — proving one-one via the implication f(x1)=f(x2)⇒x1=x2f(x_1)=f(x_2)\Rightarrow x_1=x_2, and proving onto by solving f(x)=yf(x)=y for an arbitrary yy in the codomain — plus the sharper habit of disproving each property with a single well-chosen counterexample. The codomain, not just the formula, decides these properties, and that single fact is where most marks are lost or won.

The core insight

A function is one-one when distinct inputs never collide in the output, and onto when every element of the stated codomain is actually reached, so classifying f:A→Bf:A\to B always requires checking both the rule and the exact codomain together, never the rule alone.

The core idea

Let f:A→Bf : A \to B be a function, with AA the domain and BB the stated codomain.

One-one (injective). ff never sends two different inputs to the same output:

f(x1)=f(x2)  ⟹  x1=x2for all x1,x2∈A.f(x_1) = f(x_2) \implies x_1 = x_2 \quad \text{for all } x_1, x_2 \in A.

where: x1,x2x_1, x_2 are arbitrary elements of the domain AA, and the implication must hold for every such pair, not just a few numbers you happened to try. Equivalently, distinct elements of AA have distinct images in BB. Graphically, for a real function, every horizontal line crosses the graph in at most one point (the horizontal line test).

Onto (surjective). Every element of the codomain is actually reached by some input:

for every y∈B, ∃ x∈A such that f(x)=y.\text{for every } y \in B, \ \exists\, x \in A \text{ such that } f(x) = y.

where: yy ranges over the whole codomain BB, and xx must come from the domain AA. Equivalently, the range of ff (the set of actual outputs) equals the codomain BB. If even one element of BB is missed, ff is not onto — older texts call this case "into." A function can be one-one only, onto only, both (a bijection), or neither, and all four combinations genuinely occur. Crucially, the same formula can change category when the codomain changes: f(x)=x2f(x) = x^2 from R\mathbb{R} to R\mathbb{R} misses every negative number, so it is not onto, but the identical rule from R\mathbb{R} to [0,∞)[0,\infty) hits every non-negative number, so it becomes onto. The rule alone never settles the question — you must read the stated codomain every time. To disprove one-one, it is enough to exhibit one pair of distinct inputs with equal outputs. To disprove onto, it is enough to exhibit one element of the codomain with no pre-image. Proving the positive statement, by contrast, needs a general argument valid for all elements — a single lucky example never proves one-one or onto.

Figure
Two arrow diagrams comparing a one-one but not onto mapping with an onto but not one-one mapping between finite sets
Reading the two tests off an arrow diagram one-one, not onto never reached A B onto, not one-one two arrows land here A B Left: every arrow lands alone (one-one), but one point of B is unreached (not onto). Right: every point of B is hit (onto), but two arrows share a target (not one-one).
Derivation AA linear function is always a bijection on the reals

The goal is to prove, in full generality and not just for one numerical example, that any real linear function f(x)=ax+bf(x) = ax + b with a≠0a \ne 0, mapping R→R\mathbb{R} \to \mathbb{R}, is simultaneously one-one and onto — a single argument that covers every such line at once, rather than re-deriving the two properties from scratch each time a new slope and intercept appear in a problem.

Step 1. Set up the one-one test. Suppose f(x1)=f(x2)f(x_1) = f(x_2) for arbitrary x1,x2∈Rx_1, x_2 \in \mathbb{R}. By the rule, ax1+b=ax2+bax_1 + b = ax_2 + b.

Step 2. Simplify the equality. Subtracting bb from both sides gives ax1=ax2ax_1 = ax_2. Since a≠0a \ne 0, division by aa is valid, giving x1=x2x_1 = x_2. So f(x1)=f(x2)f(x_1) = f(x_2) forces x1=x2x_1 = x_2 for arbitrary x1,x2x_1, x_2, which is exactly the definition of one-one — no counterexample exists because the algebra rules one out for every pair.

Step 3. Set up the onto test. Take an arbitrary y∈Ry \in \mathbb{R}, the codomain. We must find some x∈Rx \in \mathbb{R} with f(x)=yf(x) = y, i.e. solve ax+b=yax + b = y for xx.

Step 4. Solve and verify. Since a≠0a \ne 0, x=y−bax = \dfrac{y-b}{a} is a well-defined real number for every real yy. Substituting back, f(y−ba)=a⋅y−ba+b=(y−b)+b=yf\left(\dfrac{y-b}{a}\right) = a\cdot\dfrac{y-b}{a} + b = (y-b) + b = y. So every y∈Ry \in \mathbb{R} has a pre-image in R\mathbb{R}, proving ff is onto.

Step 5. Combine. Because ff is both one-one and onto, f(x)=ax+bf(x) = ax+b (a≠0a \ne 0) is a bijection on R→R\mathbb{R} \to \mathbb{R} for every choice of slope a≠0a \ne 0 and intercept bb — the condition a≠0a \ne 0 is exactly what Step 2's division needs, and it is the only thing that can ever go wrong.

Worked example

Let f:R→Rf : \mathbb{R} \to \mathbb{R} be defined by f(x)=x2f(x) = x^2. Determine whether ff is one-one, onto, both, or neither, and state what happens if the codomain is changed to [0,∞)[0,\infty).

Step 1. Test one-one with a counterexample. Take x1=2x_1 = 2 and x2=−2x_2 = -2; both lie in the domain R\mathbb{R} and x1≠x2x_1 \ne x_2. But f(2)=22=4f(2) = 2^2 = 4 and f(−2)=(−2)2=4f(-2) = (-2)^2 = 4, so f(x1)=f(x2)f(x_1) = f(x_2) despite x1≠x2x_1 \ne x_2. This single pair is enough: ff is not one-one.

Step 2. Test onto against the stated codomain R\mathbb{R}. The codomain includes negative numbers, e.g. y=−1y = -1. Solving x2=−1x^2 = -1 for real xx is impossible, since the square of any real number is never negative. So y=−1y = -1 has no pre-image, and ff is not onto on R→R\mathbb{R} \to \mathbb{R}.

Step 3. Change only the codomain to [0,∞)[0,\infty), keeping the same rule and domain. Now take an arbitrary y∈[0,∞)y \in [0,\infty); since y≥0y \ge 0, x=yx = \sqrt{y} is a real number and f(y)=(y)2=yf(\sqrt{y}) = (\sqrt{y})^2 = y. Every yy in this smaller codomain now has a pre-image, so the same rule is onto once the codomain is restricted. One-one-ness is unaffected by the codomain change, so ff is still not one-one — it remains onto but not one-one on R→[0,∞)\mathbb{R} \to [0,\infty).

Answer: f(x)=x2f(x) = x^2 from R→R\mathbb{R} \to \mathbb{R} is neither one-one nor onto, but the identical rule from R→[0,∞)\mathbb{R} \to [0,\infty) is onto (still not one-one).

Competitive stretch

If instead the domain is also restricted to [0,∞)[0,\infty), with codomain [0,∞)[0,\infty), then f(x)=x2f(x) = x^2 becomes a full bijection: Step 1's counterexample x2=−2x_2 = -2 is no longer in the domain, so distinct non-negative inputs give distinct squares, and Step 3's construction x=yx = \sqrt{y} still supplies every non-negative output. Restricting both sides at once can restore both properties that restricting the codomain alone only partly fixed.

Common traps

  • Testing a handful of numeric inputs and declaring "one-one" without the general implication f(x1)=f(x2)⇒x1=x2f(x_1) = f(x_2) \Rightarrow x_1 = x_2 for arbitrary x1,x2x_1, x_2 — a few matching outputs prove nothing either way.
  • Ignoring the stated codomain when judging "onto" — the same formula can be onto or not depending on whether the codomain is R\mathbb{R}, [0,∞)[0,\infty), or something else; always compare the actual range to the given codomain, not to what looks natural.
  • Mixing up the vertical line test (confirms ff is a valid function at all) with the horizontal line test (checks one-one-ness) — only the horizontal test is relevant here.
  • Assuming any "nice" polynomial formula is automatically onto — x2x^2, ∣x∣|x|, and even x3x^3 restricted to a smaller codomain than its true range are not onto R→R\mathbb{R} \to \mathbb{R} unless the range genuinely equals the stated codomain.

Ask the tutor: Not sure whether a specific function — piecewise, or built from x3x^3 or sin⁡x\sin x — is one-one, onto, both, or neither? Ask the AI tutor to walk through the test with you step by step.

Why does the codomain matter if the rule of the function stays exactly the same?

Because one-one is about the domain (do inputs collide) while onto compares the range to the codomain (is every stated target hit). Changing the codomain does not touch the rule or the domain, so one-one-ness never changes with it, but onto-ness is defined entirely relative to the codomain you were given. f(x)=x2f(x) = x^2 from R→R\mathbb{R}\to\mathbb{R} misses every negative number and fails onto, yet the same rule from R→[0,∞)\mathbb{R}\to[0,\infty) hits everything in that smaller codomain and passes. Always check the codomain stated in the question, not the one you assume.

Is it enough to test one-one and onto using a graph, or do I need algebra?

A graph (via the horizontal line test) is a fast sanity check and can be enough to disprove one-one by spotting a horizontal line that crosses twice. But CBSE board answers expect the algebraic argument: assume f(x1)=f(x2)f(x_1) = f(x_2) and show it forces x1=x2x_1 = x_2 for one-one, or solve f(x)=yf(x) = y for xx in terms of an arbitrary yy for onto. A picture supports intuition; the implication and the explicit solving are what earn full marks.

Do I need to know about inverse functions to answer these questions?

No. This topic asks you to classify a given function as one-one, onto, both, or neither using direct tests on the stated rule, domain and codomain. Building the machinery of inverse functions from a bijection is not part of the current syllabus here, so you will not be asked to construct f−1f^{-1} from this topic — focus stays on the injectivity and surjectivity tests themselves.

Before this

Where this leads