# Maximum of a 2-argument function $f(x,y) = \frac{1}{2} \cdot (\frac{x}{x+y} + \frac{50-x}{100-x-y} )$

Is there some relatively simple way to find the maximum of this function

$$f(x,y) = \frac{1}{2} \cdot (\frac{x}{x+y} + \frac{50-x}{100-x-y} )$$

under the following constraints:

$$x\ and\ y\ are\ integers$$

$$0 \leq x \le 50$$

$$0 \leq y \le 50$$

$$the\ two\ denominators\ are\ positive$$

This function represents a probability which I came across in a probability theory problem. The problem is supposed to be simple but I find no simple solution.

I sort of found the answer by intuition and by some general trial and error... The answer is that the maximum is at $$x=1, y=0$$. I was able to 3D plot this function in Wolfram Alpha and it sort of confirms my finding.

But somehow I am not satisfied with this, I am looking for something more rigorous. I tried derivatives (fixing $$x$$ and letting $$y$$ vary and then the reverse), but the expressions come out quite unpleasant.

Any alternatives ideas or suggestions would be quite helpful.

Original problem:
You have two piles of marbles:
1st pile: $$x$$ white, $$y$$ black marbles.
2nd pile: $$50-x$$ white, $$50-y$$ black marbles.
So... $$50$$ marbles of each color, $$100$$ marbles in total.
Both piles are not empty.
You pick a pile at random, and then from it, you pick a marble at random.
You want to maximize the probability of the event
A = {the marble selected is white}.
What should be $$x$$ and $$y$$ then (to maximize that probability)?

• A rule of thumb: When the two fractions are equal, usually the function reaches either a minimum or maximum. I would set them equal to each other and solve. – Don Thousand Sep 26 '18 at 18:20
• Shouldn't it not be $$0 \le y\le 50$$? – Dr. Sonnhard Graubner Sep 26 '18 at 18:25
• Try $$x=49,y=50$$and the maximum is given by $$\frac{272}{99}$$ – Dr. Sonnhard Graubner Sep 26 '18 at 18:30
• @Dr. Sonnhard Graubner Seems you have a typo. It cannot be 272/99. Also... what do you mean try? I know the answer, but I cannot quite put together a rigorous proof. – peter.petrov Sep 30 '18 at 8:20
• Yes indeed, there is an error, it must be $$\frac{74}{99}$$ for $$x=1,y=0$$ – Dr. Sonnhard Graubner Sep 30 '18 at 8:46

In terms of probability, this means that in one pile, we will have a probability greater than 1/2 of picking black, and in the other, we will have a probability less than 1/2. Luckily, we can maximize both of these at the same time, as $$49/99$$ is the closest we'll get to one half, and $$1$$ is the closest we'll get to $$1$$.
Note: The maximum of your function is a bit weird, as if we set $$y=0$$, then the function strictly increases as $$x\to 0^+$$, but it is discontinuous at $$0$$, so that's why I prefer a nice written explanation which sticks to the integers.