# difference between function and relation?

What is the difference between function and relations ? What are the characteristics of function and relations? What are the similarities and contrasts between relations and functions ? Examples will be much appreciated , thanks !

• In non formal terms: A function defines that one input only has ONE output. A relation does not require that. One input can have many outputs. So a (non vertical) line is a function, but a points on a circle form a relation – imranfat Sep 17 '16 at 15:18
• One could call relations "multi-valued functions". – Roland Sep 17 '16 at 17:36
• Sometimes I like to think of a relation $R$ as a boolean function that takes two arguments $R(x,y)$ and outputs either $true$ or $false$ whether $(x,y)$ belongs to $R$ or not. For example say $R$ is the "$\leq$-function", then $R(2,3) = true$. Of course this is not the formal definition, just a way of thinking. – Zubzub Sep 17 '16 at 17:39

Relation between sets $X$ and $Y$ is a triple $(X,Y,R)$ where $R$ is an arbitrary subset of $X\times Y$.

Example 1. Relation $\le$ between integers is $(\mathbb Z,\mathbb Z, R)$ where $(x,y)\in R$ if $x$ is less than or equal to $y$, e. g. $(2,3)\in R$, $(3,2)\notin R$. This is an example of a total order relation.

Example 2. Biological relation between animals $$\big(\mathrm{animals},~\mathrm{animals},~\{(x,y)\mid x,y\text{ are the same species}\}\big)$$ is an example of equivalence relation.

Function (map) is a relation $(X,Y,R)$ such that for every $x\in X$ there is unique element $(x,y)\in R$.

The keywords are "every" and "unique", this is the difference from general relations. $X$ is called domain, $Y$ is codomain, $\{y\mid (x,y)\in R\}$ is range, $R$ is graph of the function.

Example 3. Function $$f=\left(\mathbb R,\mathbb R,\{(x,y)\in \mathbb R^2 \mid y=x^2\}\right)\,,$$ is a parabola, usually denoted as $$f: \mathbb R\to \mathbb R,~ x\mapsto x^2\,.$$

Example 4. Function $$\big(\mathrm{animals},~\mathrm{species},~\{(x,y)\mid x\text{ belong the species } y\}\big)$$ is in fact the canonical projection of animals by equivalence relation from the example 2.

Use Google or Wikipedia for all unknown words.

In some interpretations, functions are relations with some very specific conditions. Specifically, a relation $R$ is a function is for any $x$ there is exactly one $y$ such that $xRy$.

Take, for instance, the relations on $\Bbb R$. There are a lot of relations. You might be aware of $\leq$, for instance, or the relation $\sim$ defined by $x \sim y$ iff $x-y \in \Bbb Z$.

Some of these relations are functions. For instance, the relation $R$ given by $xRy$ iff $x - y = 1$ is a function. It's usually written as $y = x-1$ or $R(x) = x-1$, but that doesn't change how it works.

'Relation' is one person to other person how to relate but function is transformation so function transform to one object to other object.

• this answer might be misguiding that relation is restricted to human relationship isn't it? – Siong Thye Goh Feb 21 '18 at 2:54