# How to maximize this function of X,Y?

I have 2 input $X$ and $Y$ which are both positive integers. I have to maximize this function

Let $A=\min(Y/4,X/2)$ , $B=\min(W/2,Y/2)$, $C=\max(A,B)$, and $D=\max(X-W,Y)$.

Then $$f(X,Y)=\max_{0\leq W\leq X} C\cdot C\cdot D$$

How can this problem be solved? Is it possible to determine whether this function will have a single global maximum or not?

• W can vary from 0 to X . Apr 9 '13 at 21:14
• @julien:W varies from 0 to X . Apr 9 '13 at 21:15
• @julien:Real values. Apr 9 '13 at 21:26
• So is my edit correct? Apr 9 '13 at 21:28

The easy part is this: If $Y\ge 2X$, then $A=X/2$, $B=W/2$, $C=B=W/2$, $D=X-W$, hence $$f(X,Y)=\max_{0\le W\le X} \frac{W^2(X-W)}4=\left.\frac{W^2(X-W)}4\right|_{W=\frac23X}=\frac{X^3}{27}.$$ But if $X\le Y<2X$, you should try to find $$f(X,Y)=\max\left\{\max_{0\le W\le Y/2}C^2D, \max_{Y/2< W\le X}C^2D\right\}$$ and the case $Y<X$ need still a bit more consideration.