# Difference between a function and a graph of a function?

Formally, I learned that a function $f: X \to Y$ is a subset $f \subset X \times Y$ subject to the condition that for every $x \in X$, there is exactly one $y \in Y$ such that $(x, y) \in f$. We write $y = f(x)$.

The graph of a function $f: X \to Y$ is the set $\{(x, f(x)) : x \in X\}$.

Based on these two definitions, the graph of a function is, well, just the function (i.e $\operatorname{graph} f = f$), which makes me wonder why would you consider the “graph” of a function if it doesn’t tell you anything new?

#### Solutions Collecting From Web of "Difference between a function and a graph of a function?"

Consider the following two functions: $f:\mathbb R \to \mathbb R$, $f(x)=\sin(x)$, and $g:\mathbb R \to [-1,1]$, $g(x)=\sin (x)$. As functions, these two things are different simply because the codomain of one is different than the codomain of the other. However, since for all $x\in \mathbb R$ it holds that $f(x)=g(x)$, the graphs of both functions are identical.

Some aspects of a function are completely determined just by the graph, but some are not. For instance, injectivity of a function is completely determined by its graph, while surjectivity does not. I.e., $f$ above is not surjective, while $g$ is surjective.

When thinking of a function as a process it is natural to specify its domain (thought of as possible inputs) and its codomain (possible outputs) without committing oneself that every output really is attained. Here is an extreme example. Let $f:\mathbb R \to \mathbb R$ be given by $f(x)=e^{\sin(x)}\cdot\cos(x)$. I just defined the function without worrying about its precise image, which could be a pain to figure out if all I want to do is define the function.

Some people use the definition of function along these lines:

A function from $X$ to $Y$ is an ordered triple $(X,f,Y)$, where $f\subseteq X\times Y$ and for each $x\in X$ there is unique $y\in Y$ fulfilling $(x,y)\in f$.

(Some examples of texts using this definition can be found if you try to search for function ordered triple or something similar in Google Books.)

This is basically the same thing as saying:

We consider two functions $f\colon X\to Y$, $g\colon Z\to W$ to be equal if (and only if) $X=Z$, $Y=W$ and $f(x)=g(x)$ for each $x\in X$.

So for two functions to be equal, they need to have the same codomain.

(A reasonable search query to find some text including this might be “two functions” equal.)

There are many situations where this distinction is unimportant, so the functions $\sin \colon \mathbb R \to \mathbb R$ and $\sin \colon \mathbb R \to [-1,1]$ are often consider the same. (And the are the same according the definition in the OP. If we use the definition as “function is a subset of $X\times Y$ such that…”, then a function is indeed equal to its graph.)

But there are also situations where the distinctions is important, for example speaking about surjective functions only makes sense if you specify the codomain. (So if you use the definition from the OP, you would have to consider surjectivity as property of the pair $(f,Y)$, i.e. a function and a set containing the range of this function, rather then a property of the function $f$.)

Wikipedia article also has a section on alternative definitions of a function. Just in the case the article will be reorganized in the future, I am also adding a link to the current revision.

Well, of course, even those most hung up on set-theoretic regimentations, don’t really, really, believe that functions are identical to their graphs, i.e. identical to sets of tuples (or are identical to set-theoretic triples of domains, codomains and sets of tuples, or whatever). For a start, some functions are “too big” to have graphs according to standard set theories, e.g. the function that maps sets to their singletons. And in any case, functions belong to a different logical type to objects such as sets (including sets of tuples). A one-place function $f$ takes single arguments and outputs values; a set [so to speak] just sits there. Of course, we can feed $x$ plus $f$’s graph $G$ as two arguments to a new dyadic evaluation function which returns the value $y$ just in case $(x, y) \in G$: but — on pain of regress — we can’t keep trading in functions for their graphs.

So, the set-theoretic modelling (representation, implementation) of functions by their graphs is just that: modelling or representation or implementation, however you like to put it. And like any modelling, there are different ways to go depending on what features of what you are modelling you really care about representing. What the graph modelling (for workaday functions, if not nasties like $x \mapsto \{x\}$) nicely highlights is extensionality and plenitude (the idea that there is a function for every arbitrary pairing of arguments and values). Whether you also want to build in codomains to your definition of a function when modelling in set terms will depend on whether that is going to matter, as I think @BrianM.Scott is saying in his comment on @IttayWeiss’s answer. There is surely no question of right or wrong here, just assessments of overall neatness and convenience.

What’s going on here is that “everybody knows” what a function ought to be, and the definition of a function as being equal to its graph is just a tool for codifying that. I assure you that there’s hardly a working mathematician in the world who thinks of a function as equaling its graph. A perfectly analogous situation is the standard definition of what an ordered pair $(a,b)$ “is”. (Something like $(a,b)=\{\{a\},\{a,b\}\}$, or another equally unintuitive construct.) Giving the “definition” is just giving a set-theoretic construction that is logically sound and delivers the properties that everybody was expecting the concept to satisfy.