# Mathematical function for weighting results

I am trying to find a mathematical function that would provide certain weighting to the values of my algorithm. Namely, having two values, x,y, I would like to provide a function that would favour big differences between x and y. Ideally, it would return 1, if x = -inf and y = +inf (or vice versa) and 0, if they are equal. On top of that, I would like it to be non-linear in growth.

-

You can define a lot of such functions, the most simple choice being $1-\mathrm e^{-|x-y|}$ which admits all the requirements you've requested. We can also make it even more nonlinear: $$1 - \mathrm e^{-|x^3-y^5|}$$ not to depend explicitly on $|x-y|$ if you would like to avoid that.
You can also consider $1-\mathrm e^{-|x-y|^p}$ for $p>0$. If you would like to weight more huge differences in $x,y$ then choose $p>1$, otherwise choose $p<1$. If you know that the maximum difference is $D$ then you can simply use $$\left(\frac{|x-y|}{D}\right)^p$$ where the choice of $p$ follows the same reasons.
Any strictly monotonic function $f$, such that $\lim \limits_{x \rightarrow +\infty} f(x) \neq \infty$ could be used after a bit of linear transformations. Aside from what Ilya suggests, other natural choices could be $$1 - \frac{1}{1+|x-y|}$$ or $$\frac{2\arctan |x-y|}{\pi}$$ There is a lot of freedom here, if you know exactly what you want.