Typically, a function $f: D \mapsto R$ is described as $$\forall x \in D, \exists ! y \in R, \left(x,y\right) \in f \wedge P\left(x,y\right),$$ where $P$ is a predicate that specifies the relation between an input and the output, for instance, $y = 3x$ if $D \subseteq \mathbb{R}$ and $R \subseteq \mathbb{R}$. However, this definition does not specify what happens outside $D$. Should we explicitly specify that no element outside $D$ corresponds to an output under $f$? That is, should we use the following proposition $$\left(\forall x \in D, \exists ! y \in R, \left(x,y\right) \in f \wedge P\left(x,y\right) \right) \wedge \left(\forall x \not\in {D}, \lnot \exists y, \left(x,y\right)\in f\right)$$ to describe $f$?
My own understanding is as follows. In mathematical proofs, people are more concerned with the existence of such a function. That is, what happens outside $D$ does not matter. What matters is, such a function $f$ exists, so that the proof can move on. Specifically, when people talk about a function, they are saying: $$\exists f, \forall x \in D, \exists ! y \in R, \left(x,y\right) \in f \wedge P\left(x,y\right).$$ And they can proceed with a particular example of such a function. In such a circumstance, the information of existing $f$s outside $D$ is not of interest.