Basic definition of a Function

A function is a mathematical relation between two sets of numbers: for each element in the first set (called the domain) there is assigned exactly one element in the second set (called the codomain or range).
In other words:
A function is like a machine: it takes an input, applies an operation, and produces a single output.

Notation

where f is the function, X is the domain and Y is the codomain.
If we give the function a value x, it returns a value:

where y is the output corresponding to x.
Simple example

- If we input
, we get
.
- If we input
, we get
.
Graphical example
When plotting a function on the plane, each value of x has a unique output point y.
To verify this, we use the vertical line test: if a vertical line intersects the graph at more than one point, it is not a function.


In summary:
A function is a relation that assigns each input value to exactly one output value.