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:

  1. 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.
  2. 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.

Three arrow diagrams showing a function, a non-function missing an output, and a non-function with two outputsThree pairs of ovals are shown vertically. The top pair shows a valid function: every element on the left has exactly one arrow to the right. The middle pair shows a non-function where element 3 has no arrow. The bottom pair shows a non-function where element 1 has arrows to both a and b. Function: each input has exactly one output A B 1 2 3 a b c valid Not a function: element 3 has no output A B 1 2 3 a b c not valid Not a function: element 1 has two outputs A B 1 2 3 a b c not valid
Three arrow diagrams. The top one is a function: every element of $A$ sends exactly one arrow to $B$. The middle one fails because element $3$ has no arrow (rule 1 violated). The bottom one fails because element $1$ has two arrows (rule 2 violated).

Domain, codomain, and range

These three terms describe the input side, the potential output side, and the actual output side of a function.

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.

Arrow diagram showing domain, codomain, and range of a functionTwo ovals. The left oval labelled A contains 1, 2, 3. The right oval labelled B contains a, b, c, d. Arrows go from 1 to a, from 2 to a, and from 3 to c. Elements b and d have no arrows pointing to them. The domain is all of A, the codomain is all of B, and the range is just a and c. A (domain) B (codomain) 1 2 3 a b c d range = {a, c} ⊆ codomain
The function $f(1) = a$, $f(2) = a$, $f(3) = c$. The domain is all of $A$ (every element has an arrow). The codomain is $\{a, b, c, d\}$. The range is $\{a, c\}$ — only the elements that actually get hit by an arrow. Multiple arrows can land on the same output (both $1$ and $2$ map to $a$), but no input can send out more than one arrow.

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:

f: A \to B

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"):

f: 1 \mapsto a, \quad 2 \mapsto a, \quad 3 \mapsto c

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.

Diagram distinguishing the two arrows in function notationTwo rows. The top row shows f colon A right arrow B and labels the arrow as set-level, meaning from domain to codomain. The bottom row shows f colon x maps-to x squared and labels the maps-to arrow as element-level, meaning what happens to a specific input. f : A → B → is set-level: "from domain A to codomain B" f : x ↦ x² ↦ is element-level: "input x produces output x²"
The two arrows in function notation. The thin arrow $\to$ connects domain to codomain. The barred arrow $\mapsto$ connects a specific input to its specific output. Mixing them up is a common mistake.

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).

Vertical line test: a parabola passes, a circle failsTwo graphs side by side. The left graph shows a parabola y equals x squared. A vertical dashed line at x equals 1.5 intersects the parabola at exactly one point. The right graph shows a circle. A vertical dashed line intersects the circle at two points, so the circle fails the vertical line test. x y passes (one hit) x y fails (two hits)
Left: the parabola $y = x^2$ passes the vertical line test — every vertical line meets it at most once. Right: the circle $x^2 + y^2 = r^2$ fails — some vertical lines hit it twice, giving two $y$-values for a single $x$. A circle is a relation, but not a function of $x$.

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.

Domains of three common functions shown on number linesThree horizontal number lines stacked vertically. The first shows the domain of f of x equals x squared as the entire real line, drawn as a solid line. The second shows the domain of g of x equals 1 over x as the real line with a hollow circle at 0, indicating 0 is excluded. The third shows the domain of h of x equals square root of x as a ray starting at 0 with a filled circle and extending to the right. f(x) = x² 0 domain = ℝ g(x) = 1/x 0 domain = ℝ \ {0} h(x) = √x 0 domain = [0, ∞)
The natural domains of three common functions. $f(x) = x^2$ is defined for all real numbers. $g(x) = 1/x$ is defined everywhere except $0$ (hollow dot). $h(x) = \sqrt{x}$ is defined only for $x \ge 0$ (solid dot at $0$, ray to the right). The domain is determined by what makes the formula produce a valid real output.

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\}.

Arrow diagram for the function R mapping 1 to 2, 2 to 3, 3 to 2, 4 to 5Two ovals. The left oval A contains 1, 2, 3, 4. The right oval B contains 1, 2, 3, 4, 5. Arrows go from 1 to 2, 2 to 3, 3 to 2, and 4 to 5. Elements 1 and 4 in B have no arrows pointing to them. A B 1 2 3 4 1 2 3 4 5
The function from Example 1. Every element of $A$ sends exactly one arrow. Two arrows arrive at $2$ in $B$ (from inputs $1$ and $3$), which is allowed. Elements $1$ and $4$ in $B$ receive no arrows — they are in the codomain but not in the range.

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.

\text{Domain} = \mathbb{R} \setminus \{-2, 2\} = (-\infty, -2) \cup (-2, 2) \cup (2, \infty)

Step 3. Find the range. Set y = \frac{x}{x^2 - 4} and solve for x in terms of y.

y(x^2 - 4) = x \implies yx^2 - x - 4y = 0

This is a quadratic in x. For real solutions to exist, the discriminant must be non-negative:

\Delta = (-1)^2 - 4(y)(-4y) = 1 + 16y^2 \ge 0

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}.

Graph of f of x equals x over x squared minus 4 showing vertical asymptotes at x equals negative 2 and x equals 2The graph of f of x equals x over the quantity x squared minus 4. There are vertical dashed lines at x equals negative 2 and x equals 2 showing vertical asymptotes. The curve has three branches: one to the left of x equals negative 2, one between negative 2 and 2, and one to the right of x equals 2. The graph extends to all y-values, confirming the range is all real numbers. x y −2 2
The graph of $f(x) = \frac{x}{x^2 - 4}$. Vertical asymptotes at $x = -2$ and $x = 2$ (dashed lines) mark where the function is undefined — these are the points excluded from the domain. The three branches of the curve collectively cover every $y$-value, confirming that the range is all of $\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

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:

n^m

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.

Interactive parabola with draggable point demonstrating the vertical line testThe parabola y equals x squared is drawn. A red draggable point sits on the curve. As the point is dragged horizontally, it traces along the parabola, always at exactly one y value for each x value. Readouts show the current x and y coordinates. x y −1 1 2 drag the red point
Drag the point along $y = x^2$. At every position, there is exactly one $y$ for each $x$ — the function rule in action. The readout shows coordinates updating as you move.

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.