# Is there a function or anything else that gives the same result on a set?

i want to know if there is a function for example that gives the same result for a set of noncontiguous reals. i want to have these results

f(10)=25 f(25)=25 f(34)=25 f(85)=25 f(14)=25 f(13)=25 for example

in fact i have:
– A number between 1 and 536870912
– Several sets of noncontiguous numbers
– A black box which must do a transformation to the sets
– Each transformation must be unique and gives a number between 1 and 255
I want to know which thing (function or anything else ) that i can have in the black box that does this transformation?

{4, 212, 10, 35000} ==> f(x) ==> 250
{584, 12, 140, 5} ==> f(x) ==> 15
I mean passing a given set by f(x) gives always the same result for the passed set
or i can imagine that for each element of a set i can have
f(4)=250, f(212)=250, f(10)=250, f(35000)=250

Thank you

#### Solutions Collecting From Web of "Is there a function or anything else that gives the same result on a set?"

Note that a function $f: A \to B$, where $A$ and $B$ are sets, is a rule that assigns to each element $a$ in $A$, a single element $f(a)$ in $B$. So your new question is no less trivial than the first one you asked, in which one solution was the constant function $f(x) = 25$, defined, say on $\mathbb{R}$. It is just a matter of writing down the appropriate rule (though it is a wholly different matter if you want it to be, say, continuous, differentiable or polynomial – in that case, something like Dennis Gulko’s answer is more appropriate).

If I’m interpreting your question correctly, you have a collection $A_1, A_2, \ldots, A_n$ of finite sets of real numbers, and you want the function to assign to each member of the set $A_i$ the number $a_i$. So, we can define a function $f: A \to \mathbb{R}$, whose domain $A$ is $A_1 \cup A_2 \cup \ldots \cup A_n$, where
$$f(x) := a_i, \text{ if } x \in A_i$$
Note that in order for this to be unambiguous, no two sets can have an element in common (in other words, $A_i \cap A_j = \emptyset$ whenever $i \neq j$).

You should use polynomial interpolation.
If you want a polynomial $f(x)$ that at the points $x_1,…,x_n$ has value $y_1,…,y_n$ respectively, define the following:
$$p_i(x)=\frac{(x-x_1)\cdot…\cdot\widehat{(x-x_i)}\cdot…\cdot(x-x_n)}{(x_i-x_1)\cdot…\cdot\widehat{(x_i-x_i)}\cdot…\cdot(x_i-x_n)}$$
(where $\widehat{(x-x_i)}$ denotes a term that is not included)
Now $p_i(x_j)=0$ for all $j\neq i$ and $p_i(x_i)=1$.
Define $f(x)=\sum_{i=1}^n y_ip_i(x)$.