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?


Solution 1:

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.

Solution 2:

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.