Different understandings of a function: defining $f: X \to Y$ by $f(x)=y$, vs defining $f=\{(x,f(x))\mid x\in X\}$ I have a question. Is it more productive or rigorous to think of a function as a rule that tells us how to "map" or "associate" elements from one set to another, or as a set of ordered pairs containing elements of one set (the domain) "mapped to" or "associated with" elements of another set? Or is there a context in which it makes more sense to think of a function one way vs another?
To expand on this, I've realized that I conceptualize each of the following ways of defining a function in two different ways:
$$\text{Define}\; f: X \to Y \;\;\text{by}\;\;f(x)=y$$
or
$$\text{Define the set}\; f = \{(x,f(x)) \mid x \in X\}$$
When a function is defined in the first manner, I tend to think of it as a specific "map" or "rule" that tells us exactly how to take an element from the set $X$ and associate it with a single element from the set $Y$. I tend to think of this function as an object that "completes an action" in a sense - where that action is taking an element from $X$ and mapping it to $Y$.
However, when a function is defined in the second manner, it no longer seems appropriate to think of it as something that is "completing an action". The function no longer seems like a "tool" in the sense that it does when it's defined in the previous manner. It seems as though the action is already completed. In other words, instead of viewing the function as an object that maps elements from $X$ to elements of $Y$, I tend to view the function as the result of a mapping from $X$ to $Y$.
But don't both of these ways of defining a function define the same mathematical object? I seem to be conceptualizing the same thing in two very different ways, which makes me wonder if my intuition is off.
 A: I wondered a very similar thing when I first encountered the formal notion of a function, so I hope my perspective is helpful.
I think the reason the notation $f(x) = y$ is often associated with a 'rule' is that typically $f(x)$ is written as some combination of operations on $x$, for example $f(x) = x^2-5x+6$. I.e. there is some necessary 'computation' to be performed, and once you perform that computation, you 'know' what $f(x)$ is. In this sense, the intuition that $f$ is 'doing something' or 'acting' on $x$ is entirely natural, and I think a perfectly reasonable intuition to have.
However, I think the issue arises because of the a slight gap between the 'rule', and what the actual function is. In our above example, say we have $f(x) = x^2-5x+6$, restricting ourselves to the real numbers. Note though this 'rule' is not itself a function; rather there is an implicit understanding that this rule induces a function $f: \mathbb{R} \rightarrow \mathbb{R}$, where $f = \{(x,f(x)):x\in \mathbb{R}\} = \{(x,x^2-5x+6): x \in \mathbb{R}\}$.
In particular, I hope this addresses why you feel $f$ is "completed" in one case but not the other. I think in the former case, you are viewing the rule as the function itself, and hence, you think the function is 'doing' something to $x$. But of course, we have just seen that while implicitly related, the function and rule are indeed distinct.
In fact, we can see this in action by realising not all 'rules' will give us functions. For example, if I tell you $f(x) = \text{arcsin}(x)$, this is not a well defined function unless we appropriately specify the domain and codomain. That is to say, sometimes just giving a 'rule' is ambiguous, and it should be seen that the 'rule' is NOT the same thing as the function itself.
A: Both are very important. What matters is that you realize that to a certain $x\in X$, there is a unique $y\in Y$ such that $f(x)=y$. Sometimes one viewpoint is more useful. Typically looking at functions as "rules" to map elements from one object to another are well suited to analysis or algebra, whereas considering functions in the second manner puts both spaces on the same level in a sense. For instance, your second definition naturally leads to the concept of a graph of a function, which is quite useful in geometry and functional analysis.
A: 
Is it more productive or rigorous to think of a function as a rule that tells us how to "map" or "associate" elements from one set to another (...)

This point of view is just an interpretation of the meaning of a function, it is not really rigorous After all, what should a "rule" mean? Or, what should "to map" or "to associate" mean?
But there is no problem of seeing a function this way, as long as you understand that it is the intuition behind a function.
As a matter of fact this approach is used in order to hind the technalities behind the definition of a function, usually aiming computational aspects.
If you want to know what a function really is, from a rigorous standpoint you have to rely on set theory. By definition, a binary relation from a set $X$ to a set $Y$ is a subset
$$R\subset X\times Y.$$
We usually define
$$xRy\Leftrightarrow (x, y)\in R.$$
Now, a function from $X$ to $Y$, by definition, is a special binary relation
$$f\subset X\times Y$$
which has the properties:
$(1)$ $D(f)=X$ where $D(f)=\{x\in X: \exists y\in Y; xfy\}$
$(2)$ If $x\in D(f)$ and $y_1, y_2\in Y$ are such that $xf y_1$ and $xfy_2$, then $y_1=y_2$.
The first property mean that every element in $X$ is related to some $y\in Y$. The second mean that a given element in $D(f)$ is related to one and only one element in $Y$.
Now $y=f(x)$ is simply a notation which means $x fy$, that is,
$$y=f(x)\Leftrightarrow xyf\Leftrightarrow (x, y)\in f$$.
Notice:
$$f=\{(x, y)\in X\times Y: xfy\}=\{(x, y)\in X\times Y: y=f(x)\}=\{(x, f(x)): x\in X\}.$$
To sum up:
(1) A function $f:X\rightarrow Y$ is by definition a subset of $X\times Y$ which has special properties.
$(2)$ $y=f(x)$ is just a handy notation for saying $(x, y)\in f$. When you write $y=f(x)$ it captures the idea that a function $f$ "transforms" $x$ into $y$. It should be emphasized that is is convention issue that makes the real definition more appealing and practical.
A: I'd like to second @PtF's answer, but I do not have enough reputation to give an upvote. I think I may also add my own perspective to this. In general, I think most mathematicians do think of functions $f \colon X \to Y$ as mappings taking elements $x \in X$ to $f(x) \in Y$.
However, the set-theoretic definition is just one way to define what a function is under some foundation. If you haven't seen this before, note that the the ordered pairs
$$
\left<x, y\right> \in X \times Y
$$
are also defined to be the set $\{\{x\}, \{x, y\}\}$ which exists whenever $x$ and $y$ are sets (and in fact, ordered pairs have more definitions but this is another abstraction we don't worry about. All that matters is we have a working definition.) Thus, it is really just a personal choice whether you want to functions as maps between spaces (sets) or just sets themselves (special relations as others point out.)
Moreover, I think most set theorists themselves prefer the former! After all, set theory need not be the end-all foundation of math
