# Maximum of expression (formula related to refraction)

Let's suppose we have $n+1$ real values $d_i$ ($i=0,\ldots,n$) with $0 \le m \le d_0 \lt d1 \lt \ldots \lt d_{n-1} \lt d_n \le M$ (we don't know anymore about $d_i$), and $n$ real values $r_i \ge 1$ ($i=1,\ldots,n$) with no specified order. Then compute $c$ as follows: $$c = d_0 + \sum_{i=1}^n (d_i-d_{i-1})r_i$$

I want to get a function $S(m, M, r_1, \ldots, r_n)$ such that: $$S(m, M, r_1, \ldots, r_n) \ge c$$

What is the best (i.e. the lowest) $S(m, M, r_1, \ldots, r_n)$ for any $d_i$ satisfying the constraint above?

I suppose the best I can do is: $$S(m, M, r_1, \ldots, r_n) = (M-m) \cdot \max_{i=1}^n r_i + m$$

But I am not able to demonstrate it (not even sure it is always $\ge c$).

Any hint? Thank you!

@Michael Seifert, following your observation and noting that we can write: $$(r_i-r_{i+1})d_i = (r_i-r_{i+1} + |r_i-r_{i+1}|)\frac{d_i}{2}+(r_i-r_{i+1} - |r_i-r_{i+1}|)\frac{d_i}{2}$$

where the first term is always $\ge 0$ and the second term is always $\le 0$, and being $m \le d_i \le M$ then: $$(r_i-r_{i+1})d_i = (r_i-r_{i+1} + |r_i-r_{i+1}|)\frac{d_i}{2}+(r_i-r_{i+1} - |r_i-r_{i+1}|)\frac{d_i}{2} \le (r_i-r_{i+1} + |r_i-r_{i+1}|)\frac{M}{2}+(r_i-r_{i+1} - |r_i-r_{i+1}|)\frac{m}{2} =$$$$(r_i-r_{i+1})\frac{M+m}{2}+|r_i-r_{i+1}|\frac{M-m}{2}$$ and $$\sum_{i=0}^n (r_i-r_{i+1})d_i \le \frac{M+m}{2}(1-r_1+r_1-r_2+r_2-\ldots-r_n+r_n)+\frac{M-m}{2}\sum_{i=0}^n |r_i-r_{i+1}|=$$$$\frac{M+m}{2}+\frac{M-m}{2}\sum_{i=0}^n |r_i-r_{i+1}|\qquad (1)$$

And only if there exists $j$ such that $r_j=\max_{i=1}^nr_i$ and $1 \le r_1 \le r_2 \le \ldots \le r_{j-1} \le r_j$ and $r_j \ge r_{j+1} \ge r_{n-1} \ge r_n$ then (1) can be simplified into: $$(M-m)\max_{i=1}^nr_i+m \qquad (2)$$

However, making some numerical tests, I think the right solution is (2).

• Just an observation: note that if you define $r_0 = 1$ and $r_{n+1} = 0$, then your expression for $c$ can be rewritten as $$c = \sum_{i = 0}^{n} (r_i - r_{i+1}) d_i,$$ which may be more conducive to bound-placing. – Michael Seifert Jun 29 '18 at 15:22

Finally it turned out to be easy: $$c = d_0 + \sum_{i=1}^n (d_i-d_{i-1})r_i \le d_0 + \max_{i=1}^nr_i \cdot \sum_{i=1}^n (d_i-d_{i-1}) = d_0 + \max_{i=1}^nr_i \cdot (d_n-d_0) = d_0 (1 - \max_{i=1}^nr_i) + d_n \max_{i=1}^nr_i$$

and since the first term is always $\le 0$ and the second term is always $\ge 0$ then: $$d_0 (1 - \max_{i=1}^nr_i) + d_n \cdot \max_{i=1}^nr_i \le m (1 - \max_{i=1}^nr_i) + M \cdot\max_{i=1}^nr_i = (M - m) \cdot\max_{i=1}^nr_i + m$$

And if $r_j=\max_{i=1}^nr_i$ choosing $d_0 = \ldots = d_{j-1} = m$ and $d_j = \ldots = d_n = M$ gives exactly $c = (M - m) \cdot r_j + m = (M - m) \cdot\max_{i=1}^nr_i + m$ so there is no better boundary.