I've got confused about the definition of a function. As what the German mathematician Peter Dirichlet said is:

If a variable y is so related to a variable x that whenever a numerical value is assigned to x, there is a rule according to which a unique value of y is determined, then y is said to be a function of the independent variable x.

In this way, a function is a variable because the variable y is a function.

But here I found another definition:

A function is a relationship between a set of inputs and outputs, where each input produces only one output.

And it says that a function is a relationship.

I even saw that such a function $f : X \to Y$ can even be defined as a set of ordered pair $\{(x,y)|x \in X \land y \in Y \}$.

Doesn't this mean that a function is a set?

So what actually is a function? Is it a variable or a relationship, or another kind of mathematical object?

  • 2
    $\begingroup$ The first definition defines the function as a relation between variables. $\endgroup$
    – Doug M
    Jan 28 at 7:06
  • $\begingroup$ The third definition (as a set) needs to add a condition that different $y$ values come from different $x$ values. $\endgroup$
    – Teepeemm
    Jan 28 at 15:09
  • $\begingroup$ The first quote defines "to be a function of", where it works sort of like an adverb, while the second defines "function", where it works as an object, a noun. $\endgroup$
    – Pablo H
    Jan 28 at 16:57
  • $\begingroup$ Isn't function a "many-to-one" relation? Why different $y$ values must come from different $x$ values? $\endgroup$
    – AAAAAA
    Jan 29 at 8:22

4 Answers 4


Intuitively a function is a way of mapping a set of values (the domain) to a (possibly another) set of values (the codomain) so that each element in the domain is mapped exactly once.

The issue is how do we define this concept of "a way of mapping" that's.... not a well defined mathematical thing.

Mathematicians decide well if each item in the domain is "mapped" to another the what we actually have on our hands are a bunch of pairs if $x_{input}$ somehow "mapped" or glued to a $y_{output}$. As they are pairs we can just describe them as a set of ordered pairs where each pair is an $(x_{input},y_{output})$ ordered pair.

If it helps you do visualize it if our function is the rule $x \mapsto x^2$ or $f(x) = x^2$ we can write the function as the set of all pairs $(x,x^2)$ or $(x,f(x))$.

Thus the definition of sets is really the most concrete one. This is actually exactly the same as relationship one because the same problems we have describing what a function is, we have defining what a "relationship" is. Mathematicians who define "functions" as sets of ordered pairs will also define "relationship" as a set of ordered pairs. That is if we say $a$ relates to $b$ in some way we mean they are glued together as an ordered pair $(a,b)$ and are in the set of all pairs of relatives.

(The only difference between a function and a relation is that functions must have exactly one ordered pair for each input value. A relation may have many for a value or may have none for a value.)

The first definition? Well, that's trying to explain the writing of a function as rule between variables. That is $y = f(x) = someway\ of\ connecting\ values\ of\ x\ to\ values\ of\ y$. But it is still consistent as our rule leaves us with a set of $(x, y=f(x))$ pairs on our hands.

So all three of those are basically the same thing.


If a variable $y$ is so related to a variable $x$ that whenever a numerical value is assigned to $x$, there $\underline{is \ \ a\ \ rule}$ according to which a unique value of $y$ is determined, then $y$ is said to be a function of the independent variable $x$.

Here function means rule.

$A=\{(x,y)|x∈X,y∈Y\}$ is graph of function $f :X \rightarrow Y$ if $y=f(x)$.

$A \subset X \times Y$ is relation in general untill we assign a rule such that unique value of $y$ is determined for a give $x$.

Function is a rule.

Function is not a variable.

If value of $y$ depends on $x$ via some rule (function) $y=x^2$ then we say $y$ is function of $x$.

$y$ is a function of $x$ means $y$ is dependant variable $x$ is independant variable. Function is a rule by which we will gate value of $y$ for given $x$.

  • $\begingroup$ please ask, i will answer $\endgroup$
    – data
    Jan 28 at 7:05
  • $\begingroup$ But a random variable can is a function. $\endgroup$
    – Doug M
    Jan 28 at 7:05
  • 1
    $\begingroup$ Good answer, except I have a few little nitpicks: 1. Your explanation covers the "usual" kind of function, but there are also set-valued functions. 2. If we're dealing with function-spaces, doesn't the distinction between "function" and "variable" become less clear? I certainly may be wrong/may have misunderstood what you meant. I'd love to hear your thoughts! $\endgroup$ Jan 28 at 7:07
  • 1
    $\begingroup$ I am being a bit of a smart-ass... In the theory of probability random variables are defined as functions from the sample space to a measurable space on the probability space. You said functions are not variables, but variables can be functions. $\endgroup$
    – Doug M
    Jan 28 at 7:11
  • 1
    $\begingroup$ My main issue with this answer is that a function is a set of ordered pairs. That is how it is defined when you get down to it. This answer doesn't deny it but just avoids the issue. Which would be okay, except the OP did ask and expressed confusion to the concept. I think we owe it to them to discuss that topic $\endgroup$
    – fleablood
    Jan 28 at 7:51

A function is indeed a set. The idea of a function as a rule is the intuitive picture that we want to capture with the definition. The thing is that the most commonly accepted foundation theory for mathematics is Zermelo-Fraenkel Set Theory, which says that every object in mathematics is a set (almost every, there are parts of mathematics that require different foundations allowing objects that are not sets, like category theory). This includes functions: A function $f:X\rightarrow Y$ is a subset $G$ of $X\times Y$ such that for every $x\in X$ there is a unique $y\in Y$ such that $(x,y)\in S$. The set $S$ is the function $f$.

That being said, in everyday mathematics you will give a function as an actual rule, like $$f:\mathbb N\rightarrow\{0,1\},\qquad f(n)=\begin{cases}1 & \text{ if }n\text{ even}\\ 0 & \text{if }n\text{ odd}\end{cases}$$ and call the set $S$ above the "graph of $f$", when a set theorist would tell that the "graph" is $f$. So a function is intuitively and can be defined by giving a rule, but it is also a set.

  • $\begingroup$ So if there is a function f from {1,2,3} to {2,4,6}, can I define that f={(1,2),(2,4),(3,6)} instead of f(x)=2x? $\endgroup$
    – AAAAAA
    Jan 28 at 10:18
  • $\begingroup$ Yes, the first expression is the "real" form of $f$ in set theory and corresponds to listing each $x$ in the domain together with its corresponding value $f(x)$. Still, this only works with small domains. Imagine if you had a function $f:\mathbb N\rightarrow\mathbb N$, you can't given every single pair $(n,f(n))$, but you can give a rule or algorithm so that knowing $n$ we can deduce $f(n)$ (like $f(n)=2n$). That's why the definition of function as a "set of pairs $(x,y)$" is only to give a formal definition of functions in set theory, but is rarely used in practice. $\endgroup$
    – Alessandro
    Jan 28 at 12:49

It is a set of ordered pairs (relation) from x to y. When you say $f(3)$ you're saying grab the $y$ corresponding to the pair (3, y). A function is a relation with the restriction that "each input produces one output" to quote your definition.

In math there are many ways to define the same thing. So a function is a set, but it could also be formally or intuitively understood in other ways.

  • $\begingroup$ Does it means that a function is a set and a relation at the same time? $\endgroup$
    – AAAAAA
    Jan 28 at 10:02
  • $\begingroup$ Yep. A relation is a set. A function is a relation (with the each input -> 1 output rule) and therefore a set. $\endgroup$
    – Ben G
    Jan 28 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.