Domain of a Function
The domain of a function or relation is the set A in the mapping $$ f:A \rightarrow B $$
The domain is the set from which the function takes its inputs.
The set B is the target set and is called the codomain of the function.
The difference between domain and domain of definition
The elements of A (the domain) that are actually mapped to at least one element of B (the codomain) form a subset known as the domain of definition (or existence set) of the function f.
In general, the domain does not coincide with the domain of definition:
$$ f: D(f) \subseteq A \rightarrow B $$
The domain is the ambient space, while the domain of definition is the portion where the function is effectively defined.
Note. In some texts, the term “domain” is used differently: it is taken to mean precisely the set of elements of A that are mapped to at least one element of B under the relation R. In that usage, the domain coincides with the domain of definition.
A Practical Example
Consider two finite sets X and Y:
$$ X = \{1,2,3,4,5 \} $$
$$ Y = \{1,2,3,4,5,6,7,8,9 \} $$
and the relation/function:
$$ f: y = x^2 $$
The domain of this relation is the entire set X:
$$ \text{Dom}(f) = \{1,2,3,4,5 \} $$
The domain of definition is a subset of the domain:
$$ D_f = \{1,2,3 \} \subseteq X $$
These are precisely the elements of X whose squares lie in the codomain Y.

$$ f: 1^2 \mapsto 1 $$
$$ f: 2^2 \mapsto 4 $$
$$ f: 3^2 \mapsto 9 $$
Example 2
Consider the real function:
$$ f: y = \sin(x) $$
Here both the domain and the codomain are the set of real numbers:
$$ f: \mathbb{R} \rightarrow \mathbb{R} $$
In this case, the domain of definition coincides with the domain, since the sine function is defined for all real numbers.
