# Maximum Value of a Floor-y Function

If $x$ is an integer, find the maximum value of $$f(x)=x-\left(\lfloor r_1x\rfloor+\lfloor r_2x\rfloor+\lfloor r_3x\rfloor+...+\lfloor r_{n-2}x\rfloor+\lfloor r_{n-1}x\rfloor+\lfloor r_nx\rfloor\right)$$ Given that $\sum r_i = 1$, where $r_i \in \mathbb{Q} \space\forall i$.

So, first I applied the identity of $\lfloor r_ix\rfloor = r_ix - \{r_ix\}$ $$f(x)=x-\left(x\left(\sum r_i\right) - \left(\sum \{r_ix\}\right)\right)$$ And since $r_i$ sums to $1$, all we need to do is find the maximum value of $$f(x) =\sum \{r_ix\}$$ But $\{r_ix\} \in [0,1)$, and since we are summing from $i=1$ to $n$, and thus, there are $n$ terms in the sum, I'm tempted to say the maximum is $n-1$. A maximum value of $n$ would imply the upper bound on the fractional function is closed. Is that accurate?

• Can the $r_i$s be irrational? – Erick Wong Aug 10 '15 at 18:29
• @ErickWong, I forgot to stipulate that $r_i$ are rationals. Sorry, I'll fix the question! – Ryan Tamburrino Aug 10 '15 at 18:31
• Thanks, you should also add that $r_i \ge 0$ which you use later on but isn't specified by the question. Also, the question is phrased a bit oddly: $x$ is given, and you are asking for the max value of $f(x)$ which depends on $r_i$. It sounds like you are more interested in the case where the $r_i$ are given and you have the freedom to choose $x$ to maximize $f(x)$. Finally, I suspect you mean $x \in \mathbb N$ else this problem is a lot easier... – Erick Wong Aug 11 '15 at 0:44
• Yes, I believe this question was created with the intent of choosing an $x$ to maximize $f(x)$, but the problem specified only that $x \in \mathbb{Z}$. – Ryan Tamburrino Aug 11 '15 at 2:37
• Note that $f(-1) = n-1$ (assuming that $r_i > 0$). – Erick Wong Aug 11 '15 at 6:47

## 1 Answer

Trivially, $f(-1) = n-1$ provided all of the $r_i$ are non-zero. If $n=1$ this is obvious since $r_1 = 1$, and if $n>1$ then $0 < r_i < 1$ so $\lfloor -r_i \rfloor = 0$. This holds even for positive real $r_i$. When the $r_i$ are rational, then one can find a positive integer $x$ such that $f(x) = f(-1)$.