What is Function in Math — Definition, Types & Examples

#Math Terms
TL;DR
A function in math is a rule that assigns to every input value exactly one output value — written $y = f(x)$ where $x$ is the input and $y$ is the output. This article gives the formal definition, distinguishes a function from a general relation, covers domain and range, the vertical line test, the most-used function families, three worked examples, and the common confusions.
BT
Bhanzu TeamLast updated on June 5, 20268 min read

A function is a relationship between two sets — call them inputs and outputs — such that every input maps to exactly one output. The output may be the same for different inputs, but no input is allowed to have two different outputs.

The Formal Definition

A function $f$ from a set $A$ (the domain) to a set $B$ (the codomain) is a rule that assigns to each element $x \in A$ exactly one element $f(x) \in B$.

Three things must be true:

  1. Every input has an output. No element of the domain is left unmapped.

  2. Each input has only one output. No input maps to two different outputs.

  3. The domain and codomain are defined. "What's allowed as input" and "what's allowed as output" are part of the function.

The notation is:

$$f : A \to B, \quad x \mapsto f(x).$$

Read aloud: "$f$ from $A$ to $B$, $x$ maps to $f(x)$."

Examples:

  • $f(x) = 2x$ — input $3$, output $6$. Linear function.

  • $f(x) = x^{2}$ — input $-2$, output $4$. Quadratic function.

  • $f(x) = \sin x$ — input $90°$, output $1$. Trigonometric function.

Quick reference.

  • Definition: a rule mapping each input to exactly one output.

  • Notation: $y = f(x)$ or $f : A \to B$.

  • Domain: the set of allowed inputs.

  • Range: the set of actual outputs (a subset of the codomain).

  • Vertical line test: a graph represents a function if and only if every vertical line meets it at most once.

  • Grade introduced: CCSS-M 8.F.A.1 (function definition); NCERT Class 11 Chapter 2 — Relations and Functions.

Function vs Relation — The Key Distinction

Every function is a relation; not every relation is a function.

A relation is any rule pairing elements of one set with elements of another. A relation becomes a function only when each input has exactly one output. The vertical line test on a graph is the visual version of this rule: a vertical line that crosses the graph more than once means at least one input has multiple outputs — not a function.

Relation

Function

Input rule

Any pairing

Each input has exactly one output

Visual test

None

Vertical line test

Examples

${(1, 2), (1, 5), (2, 7)}$

${(1, 2), (2, 5), (3, 7)}$

A circle $x^{2} + y^{2} = 9$ is a relation but not a function — for $x = 0$, both $y = 3$ and $y = -3$ are valid. A vertical line through $x = 0$ crosses the circle twice.

Domain and Range

The domain of a function $f$ is the set of all valid inputs — the values of $x$ for which $f(x)$ is defined.

The range of $f$ is the set of all actual outputs — the values $f(x)$ takes as $x$ varies across the domain.

For $f(x) = \sqrt{x}$: domain is $x \geq 0$ (you can't take real square roots of negatives); range is $f(x) \geq 0$.

For $f(x) = 1/x$: domain is $x \neq 0$; range is $f(x) \neq 0$.

Finding the domain and range is the first step in graphing or analysing any function.

The Most-Used Function Families

Family

Form

Example

Linear

$f(x) = mx + b$

$f(x) = 3x + 2$

Quadratic

$f(x) = ax^{2} + bx + c$

$f(x) = x^{2} - 5$

Polynomial

$f(x) = a_{n}x^{n} + \dots + a_{0}$

$f(x) = x^{3} - 4x + 1$

Rational

$f(x) = \dfrac{p(x)}{q(x)}$

$f(x) = \dfrac{1}{x-2}$

Exponential

$f(x) = a^{x}$

$f(x) = 2^{x}$

Logarithmic

$f(x) = \log_{a} x$

$f(x) = \ln x$

Trigonometric

$f(x) = \sin x, \cos x, \tan x$

$f(x) = \sin x$

Absolute value

$f(x) =

x

Step / piecewise

depends on the piece

$\lfloor x \rfloor$ (floor)

Every member of a family shares the same algebraic structure, distinguished by parameter values — same idea as the parameter article in this category.

Three Worked Examples of Function — Quick, Standard, Stretch

Quick. If $f(x) = 2x + 5$, find $f(3)$.

Substitute $x = 3$:

$$f(3) = 2(3) + 5 = 6 + 5 = 11.$$

Final answer: $f(3) = 11$.

Standard (Wrong Path First — Where Functions Trip Students). The relation ${(1, 2), (2, 5), (1, 7), (3, 9)}$ — is this a function?

The wrong path. A student counts four ordered pairs and says, "yes, it's a function."

The flaw: counting pairs doesn't check whether each input has only one output. Look more closely: the input $1$ appears twice — once with output $2$ and once with output $7$.

The rescue. The same input $1$ maps to two different outputs ($2$ and $7$). The first condition of a function — each input has exactly one output — is violated. So this is not a function.

Final answer: Not a function (input $1$ has two outputs).

The lesson — for a relation to be a function, scan the inputs for duplicates first. If any input shows up with two different outputs, it's not a function.

Stretch. Find the domain of $f(x) = \dfrac{1}{\sqrt{x - 3}}$.

Two restrictions to handle:

  • The expression under the square root must be $> 0$ (cannot be zero because it's in the denominator, and cannot be negative because of the real square root). So $x - 3 > 0$, giving $x > 3$.

  • The denominator is automatically nonzero once $x > 3$ (the strict inequality covers it).

Final answer: domain is $x > 3$ (or $(3, \infty)$ in interval notation).

This is the version of function problem that shows up throughout NCERT Class 11 Chapter 2 and the Common Core HSF-IF.B function-analysis standards.

Where Functions Appear — Beyond the Textbook

Functions describe every relationship in modelling.

  • Physics. Position as a function of time, velocity as a function of position, force as a function of distance — every physical law is a function.

  • Economics. Demand as a function of price, GDP as a function of investment.

  • Computer science. Every line of code in f(x) = x*2 + 3 is a function — programming was built on top of the mathematical idea.

  • Biology. Population size as a function of time (exponential growth), drug concentration in the blood as a function of hours after a dose.

  • Cryptography. Modern internet security uses one-way functions — easy to compute in one direction, practically impossible to invert.

The modern definition of a function — as a rule mapping inputs to outputs — was formalised in the $1800$s by mathematicians including Peter Gustav Lejeune Dirichlet (1805–1859, Germany) and Bernhard Riemann (1826–1866, Germany). Earlier (Newton, Leibniz, Euler) had used the word "function" — functio in Latin — but in a looser sense tied to specific formulas. Dirichlet's definition — which doesn't require a formula at all, just a rule of correspondence — opened the door to modern analysis.

Tripping Points to Avoid In Function

Mistake 1: Treating any pairing as a function

Where it slips in: A list of ordered pairs with a repeated input is called a function.

Don't do this: Skip the "each input has one output" check.

The correct way: Look for duplicate inputs. If a duplicate input has different outputs, the relation is not a function.

Mistake 2: Confusing range with codomain

Where it slips in: Student says "the range of $f(x) = x^{2}$ is $\mathbb{R}$" because the codomain is $\mathbb{R}$.

Don't do this: Treat the codomain as the range.

The correct way: The range is the set of actual outputs — for $f(x) = x^{2}$ with domain $\mathbb{R}$, the range is $f(x) \geq 0$ (squaring always gives a non-negative result).

Mistake 3: Forgetting domain restrictions when computing

Where it slips in: $f(x) = 1/(x - 2)$ — student happily evaluates $f(2)$.

Don't do this: Plug in values without checking whether the input is in the domain.

The correct way: $f(2)$ is undefined for $f(x) = 1/(x - 2)$ — the denominator is zero. Check the domain before substituting.

Conclusion

  • A function is a rule that assigns each input exactly one output.

  • Notation $y = f(x)$; the input is $x$, the output is $f(x)$.

  • The vertical line test on a graph is the visual check for function-ness.

  • Domain $=$ allowed inputs; range $=$ actual outputs.

  • Most-used function families: linear, quadratic, polynomial, exponential, logarithmic, trigonometric.

  • Confusing a relation with a function — by skipping the "one output per input" check — is the most common slip.

Practice These Three Before Moving On

  1. If $f(x) = 3x - 4$, find $f(5)$.

  2. Is the relation ${(1, 4), (2, 5), (3, 4)}$ a function?

  3. Find the domain of $f(x) = \dfrac{1}{x - 7}$.

If problem 2 gave "no" because $4$ appears twice as an output, return to FAQ "Can two different inputs give the same output?"

Want a live Bhanzu trainer to walk your child through functions, domain, and graph analysis? Book a free demo class — online globally.

Book a Free Demo

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is a function in math?
A rule that assigns to each input value exactly one output value.
What is the notation $f(x)$?
"$f$ of $x$" — the output of the function $f$ when the input is $x$.
What is the difference between a function and a relation?
Every function is a relation, but a relation is a function only if each input has exactly one output.
What is the vertical line test?
A test for whether a graph represents a function: every vertical line should meet the graph at most once.
What's the domain of $f(x) = \sqrt{x}$?
$x \geq 0$ — you can't take the real square root of a negative number.
Can two different inputs give the same output in a function?
Yes. For $f(x) = x^{2}$, $f(-2) = f(2) = 4$. Same output, different inputs is fine.
What is an example of a function in real life?
A taxi fare: $F = 10 + 2d$ — for each distance $d$ (input), there's exactly one fare $F$ (output).
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →