TITLE: A problem using Lagrange multiplier 3
QUESTION [7 upvotes]: My friend ask me to solve a problem for him, and he told me if I was gonna put it on MSE, I should say this is "dual problem of support vector machine"
Anyway, I can state the problem like this. Let 
$$f=x_1+x_2+x_3+x_4+x_5+x_6\\ -x_1^2-4x_2^2-2x_3^2-\frac{1}{2}x_5^2-\frac{1}{2}x_6^2\\-4x_1x_2-2x_1x_3-4x_2x_3
+x_1x_5+x_1x_6\\
+2x_2x_5+2x_2x_6+2x_3x_5$$
Find maximum and minimum of $f$ S.T. $x_i\geq0$ $\forall i$ and $x_1+x_2+x_3=x_4+x_5+x_6$. 
I only know the Lagrange multipliers method and it seems not effective. So help me with this problem. 
Thank you.

REPLY [3 votes]: Minimization:
By taking $x_1=x_4=t$, $x_2=x_3=x_5=x_6=0$ we get
$$
f(x)=2t-t^2\to -\infty,\quad \text{as }t\to +\infty,
$$so the minimum does not exists.
Maximization: let's replace $g:=-2f$ and minimize it. We substitute also $x_4=x_1+x_2+x_3-x_5-x_6$ and complete some squares to get
\begin{align}
g(x)&=2(x_1+2x_2+x_3)^2+2x_3^2+x_5^2-2x_5(x_1+2x_2+2x_3)+x_6^2-2x_6(x_1+2x_2)-\\
&-4(x_1+x_2+x_3)
\end{align}
and $x_1+x_2+x_3\ge x_5+x_6$ plus positivity constraints.

Try minimization w.r.t. $x_5$ first. The minimum without constraints would be at $x_5=x_1+2x_2+2x_3$, but then
$$
x_1+x_2+x_3\ge x_5+x_6\quad\Leftrightarrow\quad 0\ge x_2+x_3+x_6,
$$
which together with positivity yields $x_2=x_3=x_6=0$. It means that the minimization w.r.t. $x_5$ is always going to be when the constraint is active, that is
$$
x_1+x_2+x_3=x_5+x_6.
$$
(Either it does not let $x_5$ come to $x_5=x_1+2x_2+2x_3$ and becomes active, or it does, but becomes active there anyway.)
Let's substitute now $x_5=x_1+x_2+x_3-x_6$ and try minimization w.r.t. $x_6$
\begin{align}
g(x)&=x_1^2+4x_1x_2+5x_2^2+2x_2x_3+x_3^2+2x_6^2-2x_6(x_1+x_2-x_3)-\\
&\quad -4(x_1+x_2+x_3)=\\
&=(x_1+2x_2)^2+(x_2+x_3)^2+2x_6^2-2x_6(x_1+x_2-x_3)-\\
&\quad -4(x_1+x_2+x_3)
\end{align}
subject to the constraint $x_1+x_2+x_3\ge x_6$ plus positivity. We have two possibilities here.

Case 1: $x_1+x_2-x_3\le 0$. Then the minimum is at $x_6=0$.
Case 2: $x_1+x_2-x_3\ge 0$. Then differentiation w.r.t. $x_6$ gives
$$
4x_6-2(x_1+x_2-x_3)=0\quad\Leftrightarrow\quad x_6=\frac12(x_1+x_2-x_3)\ge 0.
$$
With this $x_6$ the constraint $x_1+x_2+x_3\ge x_6$ $\Leftrightarrow$ $x_1+x_2+3x_3\ge 0$ is satisfied. The function is convex in $x_6$ and we have found a feasible critical point, thus, it is the minimum w.r.t. $x_6$.

Continuing minimization in Case 1 above. We substitute $x_6=0$ and will have to minimize
$$
g_1(x)=(x_1+2x_2)^2+(x_2+x_3)^2-4(x_1+x_2+x_3)
$$
subject to $x_1+x_2\le x_3$ plus positivity. Let's change the variables as
$$
y=x_1+2x_2,\quad z=x_2+x_3.
$$
Then we need to minimize
$$
g_1=y^2+z^2-4(x_1+z)
$$
subject to $0\le x_1\le y\le z$. Obviously, we have to take $x_1=y$ (as large as possible), hence
$$
g_1=y^2-4y+z^2-4z,\quad 0\le y\le z.
$$
Differentiation gives the critical point $y=z=2$ which is feasible. The function is convex, thus, it is the minimum. Therefore, the minimization in Case 1 is solved as
$$
x=(2,0,2,0,4,0),\quad \min=-8.
$$
Doing Case 2 above now. Substitute $x_6=\frac12(x_1+x_2-x_3)$ and minimize
\begin{align}
g_2&=\frac12x_1^2+3x_1x_2+\frac92x_2^2+x_1x_3+3x_2x_3+\frac12x_3^2-4(x_1+x_2+x_3)=\\
&=\frac12\left((x_1+3x_2+x_3)^2-8(x_1+x_2+x_3)\right)
\end{align}
subject to $x_1+x_2\ge x_3$ and positivity. The same change of variables
$$
y=x_1+2x_2,\quad z=x_2+x_3
$$
gives
$$
2g_2=(y+z)^2-8x_1-8z,\quad 0\le x_1\le y,\ z\le y\le x_1+2z.
$$
It is again obvious that minimization w.r.t. $x_1$ is done by $x_1=y$ (as large as possible), hence,
$$
2g_2=(y+z)^2-8(y+z),\quad 0\le z\le y,
$$
and we get the minimum of $g_2$ as $-8$ when $y+z=4$.
Finally the maximization of $f$ has the parametric solution
$$
x=(2,0,2,0,4,0)+t(1,0,-1,0,-1,1),\quad 0\le t\le 2,
$$
and the maximum is $4$.