3
$\begingroup$

Given an order set of some number, $S=\{1.3, 1.7, 1.9, 2.8\}$, I would like to know how can I mathematically define a function that round a value to the nearest number in the set $S$.

For example, if I give the value 1.72, I'll receive back the number 1.7.

  • 0
    @PauloFracasso: The actual set is immaterial. In your original $S$, there are $2^3=8$ different functions that satisfy the desired property, determined by which of each pair of consecutive numbers will be favored over the other when rounding from their midpoint. (In general, if $|S|=n+1$, there will be $2^n$ such functions.) Two of these are simple to describe (always round up, or always round down). For more detail (and the precise definitions), see my comment on Marvis's answer, and Marvis's edited answer.2012-06-26

1 Answers 1

2

One possible candidate is $f(x) = \min \{\text{arginf}_{y \in S} \vert x-y\vert\}$

  • 0
    Absolutely! Even though it isn't what *I* suggested. ;-)2012-06-26