# Calculate max/min of $x_1 x_2+y_1 y_2+z_1 z_2+w_1 w_2$

What is a good way to calculate max/min of $$x_1 x_2+y_1 y_2+z_1 z_2+w_1 w_2$$ where $x_1+y_1+z_1+w_1=a$ and $x_2+y_2+z_2+w_2=b$ and $x, y, z, w, a, b \in \mathbb{N} \cup \{0 \}$, and please explain your answer (how your result comes out).

-
You can solve this by showing that if $c>d$ then $c(e+1)+df>ce+d(f+1)$. – Henry May 16 '11 at 6:40
henry's hint hits the point i think, but thanks all. – syffinx May 16 '11 at 10:17

$$0 \leq x_1x_2+y_1y_2+z_1z_2+w_1w_2 \leq (x_1+y_1+z_1+w_1)(x_2+y_2+z_2+w_2) = ab$$

Since you want a solution in $\mathbb{N}$ including $0$, you get equality only when $x_1 =a$ and $x_2=b$. The other variables will be zero. You get similar solutions by shifting the variables around.

To minimize the expression, you will have $x_1 = a$ and either $y_2$, $z_2$ or $w_2$ set to $b$ and all other variables set to zero.

-
There are other ways to minimize, e.g., $z_1=w_1=x_2=y_2=0$, $x_1+y_1=a$, $z_2+w_2=b$ gives you some freedom in choosing four of the variables. – Gerry Myerson May 16 '11 at 13:14

I take it your natural numbers start at $1$. To maximize, let $x_1=a-3$, $x_2=b-3$, all other variables $1$. To minimize, $x_1=a-3$, $y_2=b-3$, all other variables $1$.

-
thanks,but explain your method please. – syffinx May 16 '11 at 6:31
After syffinx changed the question, you will have to change this to $x_1=a$, $x_2=b$ and the others all $0$. – Henry May 16 '11 at 6:36
Sorry, I don't speak to people whose natural numbers begin with zero. Just kidding. Anyway, the minimization is trivial, as it gives zero, and you can't hope to get anything less. For the maximization, I defer to svenkatr's answer and/or Henry's comment. – Gerry Myerson May 16 '11 at 13:17