In short
A function from a set A to a set B is a relation in which every element of A is paired with exactly one element of B. The set A is the domain, B is the codomain, and the set of all outputs that actually appear is the range. The notation f: A \to B names the function f, its domain A, and its codomain B. On a graph, the vertical line test checks whether a curve represents a function: if every vertical line hits the curve at most once, it is a function.
Suppose your school assigns each student exactly one roll number. Priya is 14, Rahul is 27, Ananya is 3. Every student gets a number, and no student gets two different numbers. That assignment — student in, roll number out, no ambiguity — is a function.
Now consider a different assignment: each student is paired with the subjects they study. Priya studies Mathematics and Physics. Rahul studies Mathematics, Physics, and Chemistry. Here, one input (Priya) maps to multiple outputs (Mathematics, Physics). That is still a perfectly valid relation, but it is not a function. A function demands that each input produce exactly one output, no more.
That single demand — one input, one output — is what separates functions from the broader world of relations. It is a small rule, but it makes functions far more useful. With a function, you can feed in a value and know, without ambiguity, what comes out. That predictability is why functions are the central object in all of mathematics after class 10.
A function as a special relation
From the article on relations, you know that a relation from A to B is any subset of the Cartesian product A \times B. A function is a relation with one extra constraint.
Function
A function from a set A to a set B is a relation f \subseteq A \times B such that:
- Every element of A appears as a first coordinate — for every a \in A, there exists some b \in B with (a, b) \in f.
- No element of A appears with two different second coordinates — if (a, b_1) \in f and (a, b_2) \in f, then b_1 = b_2.
Together: every element of A is paired with exactly one element of B.
The first condition says the function is defined everywhere on A — no input is left without an output. The second condition says the output is unique — no input maps to two different things. A relation that violates either condition is not a function.
Take A = \{1, 2, 3\} and B = \{a, b, c\}. The relation \{(1, a), (2, b), (3, c)\} is a function: every element of A appears exactly once as a first coordinate. The relation \{(1, a), (2, b)\} is not a function, because element 3 has no pair. The relation \{(1, a), (1, b), (2, c), (3, a)\} is not a function, because element 1 is paired with both a and b.
Domain, codomain, and range
These three terms describe the input side, the potential output side, and the actual output side of a function.
- The domain of f is the set A — every element from which the function accepts an input. For a function (unlike a general relation), the domain is always the entire set A, because rule 1 requires that every element of A be paired.
- The codomain is the set B — the set where the outputs could live.
- The range (also called the image) is the set of outputs that actually appear: \text{range}(f) = \{f(a) \mid a \in A\}. The range is always a subset of the codomain: \text{range}(f) \subseteq B. It can equal B (in which case the function is called onto), or it can be a proper subset of B.
Here is the crucial difference between codomain and range. Take f: \{1, 2, 3\} \to \{a, b, c, d\} defined by f(1) = a, f(2) = a, f(3) = c. The codomain is \{a, b, c, d\} — all four elements. The range is \{a, c\} — only the elements that are actually hit. The elements b and d are in the codomain but not in the range.
Notice that two inputs (1 and 2) both map to the same output (a). That is perfectly fine — a function allows many inputs to share one output. What it forbids is one input going to many outputs.
Function notation: f: A \to B
The standard way to name a function and its domain and codomain in one line is:
Read this as: "f is a function from A to B." The symbol f is the name, A is the domain, B is the codomain, and the arrow \to says "maps to." When you write f(x) = x^2 alongside f: \mathbb{R} \to \mathbb{R}, you are saying: the function named f takes a real number x as input, squares it, and produces a real number as output.
The notation f(x) means "the output of f when the input is x." It does not mean f multiplied by x. The parentheses here are not arithmetic parentheses — they are function parentheses, and they hold the input.
You will sometimes see other letters: g, h, \phi, T. The letter does not matter — it is just a name. What matters is the rule that assigns each input to exactly one output.
The mapping notation
For small finite functions, you can list out the pairings using the symbol \mapsto (read "maps to"):
The arrow \to describes domain and codomain (f: A \to B). The arrow \mapsto describes what happens to a specific element (1 \mapsto a). Keep these two arrows separate in your head.
The vertical line test
When a function maps real numbers to real numbers — the kind you graph on the xy-plane — there is a quick visual test to check whether a curve represents a function.
Draw the curve. Now imagine sweeping a vertical line across the x-axis from left to right. If every vertical line crosses the curve at most once, the curve is a function. If any vertical line crosses the curve at two or more points, the curve is not a function — because that means one input (x-value) has two outputs (y-values).
The parabola y = x^2 passes: for any x, there is exactly one y. The circle x^2 + y^2 = r^2 fails: for most values of x between -r and r, there are two values of y (one positive, one negative). A circle is a valid relation — it is a perfectly good subset of \mathbb{R} \times \mathbb{R} — but it is not a function from \mathbb{R} to \mathbb{R}.
The vertical line test is not a theorem you need to prove; it is a direct consequence of the definition. "Each input has exactly one output" means each x produces at most one y. A vertical line at x = c passes through all points (c, y), so if two points lie on the curve at x = c, the curve assigns two outputs to the same input and violates the function rule.
Real-valued functions
Most functions you will work with in class 11 and 12 are functions from \mathbb{R} to \mathbb{R} (or from a subset of \mathbb{R} to \mathbb{R}). These are called real-valued functions of a real variable. The input is a real number, and the output is a real number.
For these functions, the domain is the set of all real numbers x for which the formula actually produces a valid output. When someone writes f(x) = \sqrt{x}, the domain is [0, \infty) — you cannot take the square root of a negative number (in \mathbb{R}). When someone writes g(x) = \frac{1}{x}, the domain is \mathbb{R} \setminus \{0\} — everything except 0, because division by zero is undefined.
If a problem says "find the domain of f(x) = \frac{1}{\sqrt{x - 3}}," you are looking for all x where the expression makes sense. You need x - 3 > 0 (strictly, because the square root is in the denominator, and \sqrt{0} = 0 would make the denominator zero). So the domain is (3, \infty).
Two worked examples
Example 1: Determine whether $R = \{(1, 2), (2, 3), (3, 2), (4, 5)\}$ is a function from $A = \{1, 2, 3, 4\}$ to $B = \{1, 2, 3, 4, 5\}$, and if so, find its domain, codomain, and range
Step 1. Check rule 1: does every element of A appear as a first coordinate?
The first coordinates in R are 1, 2, 3, 4. That is all of A.
Why: rule 1 requires the function to be defined on every element of A — no element can be left without an output.
Step 2. Check rule 2: does any element of A appear with two different second coordinates?
1 maps to 2 only. 2 maps to 3 only. 3 maps to 2 only. 4 maps to 5 only. No element has two outputs.
Why: rule 2 requires uniqueness of output — if any input had two arrows, the relation would not be a function.
Step 3. Since both rules are satisfied, R is a function. Now identify the three key sets.
Domain = A = \{1, 2, 3, 4\}. Codomain = B = \{1, 2, 3, 4, 5\}. Range = \{2, 3, 5\} (the set of second coordinates that actually appear).
Why: the range collects only the outputs that are actually used. Here 1 and 4 are in the codomain but not in the range — no input maps to them.
Step 4. Observe that f(1) = 2 and f(3) = 2: two different inputs share the same output. This is allowed.
Result: R is a function with domain \{1, 2, 3, 4\}, codomain \{1, 2, 3, 4, 5\}, and range \{2, 3, 5\}.
The arrow diagram confirms visually what the algebra says: every element on the left has one arrow, and the right side shows that \{2, 3, 5\} are the only elements actually reached.
Example 2: Find the domain and range of $f(x) = \frac{x}{x^2 - 4}$
Step 1. Find the domain — determine where the formula is defined.
The expression is undefined when the denominator is zero. Solve x^2 - 4 = 0: (x-2)(x+2) = 0, so x = 2 or x = -2.
Why: division by zero is undefined, so you must exclude every x that makes the denominator vanish.
Step 2. State the domain.
Step 3. Find the range. Set y = \frac{x}{x^2 - 4} and solve for x in terms of y.
This is a quadratic in x. For real solutions to exist, the discriminant must be non-negative:
Why: the discriminant 1 + 16y^2 is always positive (since y^2 \ge 0, the sum 1 + 16y^2 \ge 1 > 0). So for every real y, there exists a real x that maps to it — provided the solution x is in the domain.
Step 4. Check whether every y is actually achieved. Since \Delta > 0 for all y, the quadratic in x always has two real roots. For each y, at least one of the two roots avoids x = \pm 2 (you can verify that f(2) and f(-2) are undefined, but no finite y-value requires x = \pm 2 as its only solution). So the range is all of \mathbb{R}.
Result: Domain = \mathbb{R} \setminus \{-2, 2\}. Range = \mathbb{R}.
The graph shows the vertical asymptotes at x = \pm 2 where the denominator vanishes, and the curve sweeps through every horizontal level, confirming the range.
Common confusions
-
"A function must be given by a formula." Not true. A function is any rule that assigns exactly one output to each input. A table, a graph, a verbal description ("assign each state its capital"), or a formula — all are valid ways to specify a function. Formulae are the most common in class 11 algebra, but they are not the only way.
-
"Domain and codomain are the same thing." No. The domain is the input set A; the codomain is the target set B. They can be the same set (as in f: \mathbb{R} \to \mathbb{R}), but conceptually they play different roles.
-
"Range and codomain are the same thing." Only when every element of B is actually an output. In general, range \subseteq codomain. The distinction becomes critical when you study onto functions.
-
"If two inputs give the same output, it is not a function." It is. A function forbids one input from going to two outputs. It does not forbid two inputs from going to the same output. The function f(x) = x^2 sends both 3 and -3 to 9, and it is still a function.
-
"The vertical line test applies to all functions." Only to functions from \mathbb{R} (or a subset) to \mathbb{R}, drawn on the standard xy-plane. For functions between finite sets, or functions in higher dimensions, the test does not apply. It is a graphical shortcut, not a universal theorem.
Going deeper
If you have the definition, the notation, the domain-codomain-range distinction, and the vertical line test, you have the toolkit for the next several chapters. The rest of this section is for readers who want to see the formal set-theoretic underpinning and one subtle point about codomain.
The set-theoretic definition
In formal set theory, a function f: A \to B is defined as a triple (A, B, G_f), where G_f \subseteq A \times B is the graph of f — the set of ordered pairs \{(a, f(a)) \mid a \in A\}. The reason for including A and B in the definition (rather than just G_f) is that the codomain B cannot be recovered from the graph alone. Two functions can have the same graph but different codomains: f: \mathbb{R} \to \mathbb{R} defined by f(x) = x^2 and g: \mathbb{R} \to [0, \infty) defined by g(x) = x^2 have the same set of ordered pairs, but g is onto while f is not, because their codomains differ. Whether a function is onto depends on the codomain you declare, not just the rule.
Number of functions
If |A| = m and |B| = n, how many functions are there from A to B? Each element of A must map to exactly one element of B, and there are n choices for each. Since the m choices are independent, the total is:
Compare this with the number of relations from A to B, which is 2^{mn}. For m = 3, n = 2: there are 2^3 = 8 functions but 2^6 = 64 relations. Functions are a tiny fraction of all relations — the uniqueness constraint is strict.
An interactive look at function graphs
Drag the red point along the parabola below. For every x-position, notice that the point sits at exactly one y-value — the curve never doubles back on itself vertically. That is the vertical line test, made tangible.
Where this leads next
You now know what a function is, how to read the notation f: A \to B, and how to identify domain, codomain, and range. The next set of articles builds on this foundation.
- Ways to Define Functions — explicit formulae, piecewise definitions, implicit equations, and parametric descriptions.
- Types of Functions — injective (one-one), surjective (onto), bijective, and why these classifications matter.
- Relations — the broader framework from which functions emerge, if you want to revisit it.
- Sets — Introduction — the set notation and operations that underlie everything in this article.
- Set Operations — union, intersection, and complement, which you can apply to domains and ranges.