Suppose there are 3 non-negative integers $x$, $y$ and $z$ on the real line. We are told that $x + y + z = 300$. Without loss of generality, assume $x$ to be the smallest integer, and $z$ to be the largest.
How do I minimize $(x + z)$?
Attempt: $x + z = 300 - y$, so for a start I should maximize y. This occurs at $y = z - 1$. So, we have $x + 2z = 301$. Now, $z = \dfrac {301}2 - \dfrac x2$. $\dfrac {dz}{dx} = -\dfrac 12$. Increasing $x$ by $1$ decreases $z$ only by $\dfrac12$. So, I should pick the smallest possible $x$, which is $1$. Then, $z = 150$. $\min (x+z) = 151$.
Questions
- Is my logic correct?
- Is there a systematic way to solve questions of this kind? i.e. given non-negative numbers on the real line that sum up to a fixed value, how to minimize the sum of the largest and smallest of them?
Your logic is fine. Working with integers there are sometimes "end effects". You seem to be requiring that $y \ne z$ and an alternate solution is $(0,149,151)$ but that has the same sum of $x+z$. Without the restriction that $y \ne z$ you could have $(0,150,150)$ for a sum of $150$
Your approach is quite systematic. If you had to have $7$ different non-negative integers sum to $300$ and wanted to minimize the sum of smallest plus largest, you would argue the same way-you want the middle ones to be as large as possible, so you have six numbers that add to $300$ (or a little less), so the average one is $50$, so they are $(47,48,49,50,51,52)$ and you need to add a $3$ to make $300$ and the sum is $3+52=55$. You don't really need the derivative here.