An ordered pair is simply a pair of items written in a particular order e.g. $(a,b)$ where $a$ is the $x$ value and $b$ is the $y$ value.
Relations
A relation is a set of ordered pairs. Relations can be one of four types:
- One-to-one where one input has exactly one output e.g. one husband can only have one wife at any time
- One-to-many where one input has many outputs e.g. one drummer can play for many bands
- Many-to-one where many inputs can produce the same output e.g. many persons can follow a celebrity
- Many-to-many where many inputs can have one output and one input can have many outputs e.g. children each have two parents and any parent can have many children
Examples
Consider the relation $R:x\rightarrow y$ read as “$x$ is a friend of $y$”. The ordered pairs, for example, can be:
- $(\text{John}, \text{Mary})$ meaning John is a friend of Mary
- $(\text{Rihanna}, \text{Adelia})$ meaning Rihanna is a friend of Adelia
- $(\text{Adelia}, \text{Chris})$ meaning Adelia is a friend of Chris
The relation can thus be written as the set of ordered pairs: $$ \begin{equation}\begin{aligned} R=\{(\text{John}, \text{Mary}),(\text{Rihanna}, \text{Adelia}),(\text{Adelia},\text{Chris})\}\\ \end{aligned}\end{equation} $$
Functions
Functions are relations where any input can have exactly one output. This means that one-to-many and many-to-many relations do not qualify as functions. A function is thus a mapping between the domain and co-domain where each output appears only once.
A function must be deterministic meaning that the same input will always produce the same output every time. Thus there are only two types of relations that qualify as functions:
- One-to-one relations
- Many-to-one relations
The following is an example of a one-to-one function: $$ \begin{equation}\begin{aligned} f=\{(1,2),(2,3),(3,4),(4,5)\}\\ \end{aligned}\end{equation} $$
Because this function involves an numerical input being transformed into a numerical output in a predicable manner (the output is $1$ plus the input), we can write it as a rule involving a general unknown value $x$: $$ \begin{equation}\begin{aligned} f(x)=x+1\\ \end{aligned}\end{equation} $$
Note that writing $f=x+1$ is not wrong. We just tend to explicitly write $f(x)$ instead of $f$ to indicate to the reader that the function is in terms of one input, represented by a variable $x$. Thus a function that adds two inputs can be written as $f=x+y$ or preferably, explicitly $f(x,y)=x+y$.
The following is an example of a many-to-one function: $$ \begin{equation}\begin{aligned} g=\{(-2,4),(-1,1),(0,0),(1,1),(2,4)\}\\ \end{aligned}\end{equation} $$
Because this function involves an numerical input being transformed into a numerical output in a predicable manner (the output is the input squared), we can write it as a rule involving a general unknown value $x$: $$ \begin{equation}\begin{aligned} g(x)=x^2\\ \end{aligned}\end{equation} $$
The reliable ice cream machine analogy
You can think of functions as being reliable ice cream machines. When you put in one ingredient you get a flavour of ice cream dependent upon that ingredient. For example, chocolate will give chocolate ice cream and strawberry will give strawberry ice cream: $$ \begin{equation}\begin{aligned} f=\{(\text{chocolate},\text{chocolate ice cream}),(\text{strawberry},\text{strawberry ice cream})\}\\ \end{aligned}\end{equation} $$
It is possible, as is the case of many-to-one functions, that you can input chocolate syrup and still get an output of chocolate ice cream but that does not change the fact that chocolate begets chocolate ice cream: $$ \begin{equation}\begin{aligned} f=\{(\text{chocolate},\text{chocolate ice cream}),(\text{chocolate syrup},\text{chocolate ice cream})\}\\ \end{aligned}\end{equation} $$
The ice cream machine is reliable because we can expect that strawberry always begets strawberry ice cream. It will not produce strawberry ice cream one time and then banana ice cream another time (thus ruling out one-to-many and many-to-many relations). We can rely on it to produce the same output for any given input, every single time.
The vertical line test
Testing if a relation qualifies as a function is as easy as drawing a vertical line on the graph of the relation. If it is possible to draw such a vertical line at any point on the graph and have the line intersect with the curve more than once then the relation does not work as a function. Many intersections with the vertical line implies that one input ($x$ value) has many outputs ($y$ values).
Domain and range of a function
The domain is the set of inputs and the co-domain is the set containing the possible outputs. The range of a function consists of the elements in the co-domain that appear as outputs in the ordered pairs under the function. The range is thus a subset of the co-domain.
Created using natural intelligence