Usually, we formally represent a function by specifying the sets that are related by the function.
For example, let us consider the following function:
$i \colon \mathbb{R} \times \mathbb{R} \to \mathbb{R}$
It maps two real numbers in another real number.
But, how can I formally represent a function that maps, for example, two real numbers n1 and n2 to the interval [n1,n2]?
It is not clear to me how to do that. On of my intuitions was recognizing that an interval is just a set of real numbers (considering the example). So, it would be possible to represent the function in the following way:
$i \colon \mathbb{R} \times \mathbb{R} \to 2^{\mathbb{R}}$
Considering that $2^{\mathbb{R}}$ is the powerset of $\mathbb{R}$, that is, the set of all subsets of $\mathbb{R}$.
But this does not capture the whole information that I would like to express. For example, it does not capture the notion of beginning and end of the interval. So, I think that I can use additional information. For example, in this spirit, I think that I can define the above function in the following way:
$i \colon \mathbb{R} \times \mathbb{R} \to 2^{\mathbb{R}}$ such that, $i(x,y) = [x,y]$.
Does this make sense?
PS: Please, consider this function just as an example. I'm not interested in this particular function.