What is Function in Math — Definition, Types & Examples
What is Function in Math — Definition, Types & Examples
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.
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 ∈ A exactly one element f(x) ∈ B.
Three things must be true:
- Every input has an output. No element of the domain is left unmapped.
- Each input has only one output. No input maps to two different outputs.
- 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→B, x ↦ 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² — 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→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.
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.
| 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²+y²=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)=√x: domain is x≥0 (you can't take real square roots of negatives); range is f(x)≥0.
For f(x)=1/x: domain is x≠0; range is f(x)≠0.
Finding the domain and range is the first step in graphing or analyzing any function.
The Most-Used Function Families
| Family | Form | Example |
|---|---|---|
| Linear | f(x)=mx+b | f(x)=3x+2 |
| Quadratic | f(x)=ax²+bx+c | f(x)=x²−5 |
| Polynomial | f(x)=aₙxⁿ+⋯+a₀ | f(x)=x³−4x+1 |
| Rational | f(x)=p(x)/q(x) | f(x)=1/(x−2) |
| Exponential | f(x)=a^x | f(x)=2^x |
| Logarithmic | f(x)=logₐx | f(x)=lnx |
| Trigonometric | f(x)=sin x, cos x, tan x | f(x)=sin x |
| Absolute value | f(x) = | x |
| Step / piecewise | depends on the piece | ⌊x⌋ (floor) |
Every member of a family shares the same algebraic structure, distinguished by parameter values.
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=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?
_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). Thus, it's not a function.
Final answer: Not a function (input 1 has two outputs).
Stretch. Find the domain of f(x)=1/(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.
Final answer: domain is x>3 (or (3,∞) in interval notation).
Where Functions Appear — Beyond the Textbook
Functions describe every relationship in modeling.
- Physics. Position as a function of time, velocity as a function of position.
- Economics. Demand as a function of price.
- Computer science. Every line of code in
f(x) = x*2 + 3is a function. - Biology. Population size as a function of time.
- Cryptography. Modern internet security uses one-way functions.
The modern definition of a function — as a rule mapping inputs to outputs — was formalized in the 1800s by mathematicians including Peter Gustav Lejeune Dirichlet and Bernhard Riemann. Earlier figures had used the word "function" in a looser sense tied to specific formulas.
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.
Mistake 2: Confusing range with codomain
Where it slips in: Student equates range with codomain.
Don't do this: Treat the codomain as the range.
Mistake 3: Forgetting domain restrictions when computing
Where it slips in: Plugging in values without checking domain.
Conclusion
- A function is a rule that assigns each input exactly one output.
- Notation y=f(x) with the input as x and output as f(x).
- The vertical line test is the visual check for function-ness.
- Domain === allowed inputs; range === actual outputs.
Practice These Three Before Moving On
- If f(x)=3x−4, find f(5).
- Is the relation (1,4),(2,5),(3,4) a function?
- Find the domain of f(x)=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?"