A problem using Lagrange multiplier 3 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.
 A: The three conditions on $x_i$'s can be replaced with two
$f(x_i)=2x_1+2x_2+2x_3-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$
and 
$x_i \ge 0$.
A max or min of $f$ will occur either at a boundary or an extremum. One of these conditions will be met.
If $x_i$ is a local max or min then
I) $x_i=0$ for some $i$
II) $\nabla_ \mathbf v f(x_i) =0, \\ \forall {\mathbf v}$
$\nabla f_1=2-2x_1-4x_2-2x_3+x_5+x_6$
$\nabla f_2=2-8x_2-4x_1-4x_3+2x_5+2x_6$
$\nabla f_3=2-4x_3-2x_1-4x_2+2x_5$
$\nabla f_5=-x_5+x_1+2x_2+2x_3$
$\nabla f_6=-x_6+x_1+2x_2$
$\nabla f_i =0$ because $\nabla \mathbf v f =0$ when $\nabla f \cdot \mathbf v =0$ for all $\mathbf v$.
This is five equations and five unknowns. Expressed best as a linear transformation similar to the comments.
$$\begin{bmatrix} 
-2 & -4 & -2 & 1 & 1 \\
-4 & -8 & -4 & 2 & 2 \\
-2 & -4 & -4 & 2 & 0 \\
1 & 2 & 2 & -1 & 0 \\
1 & 2 & 0 & 0 & -1 \\
\end{bmatrix}\begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ x_5 \\ x_6 \\ \end{bmatrix}=\begin{bmatrix} -2 \\ -2 \\ -2 \\ 0 \\ 0 \\ \end{bmatrix}$$
The inverse is sought as it allows to solve for $\mathbf x$ in $\mathbf A \mathbf x = \mathbf 0 + \mathbf c$
But typically you can just use Gaussian elimination method to reduce to upper diagonal with leading coefficient of $1$. Solving for the $x_i$. 
These solutions will be possible max, min, or inflexion. Additional possible max or min in which will not be covered above are all the combinations of $x_i$ where at least one are zero. But $\nabla_{\mathbf v} f$ may not be zero here. One solution is to reduce $f$ by having combinations of $x_i$ be zero and minimizing the resulting function as above. Is it $5!$ possibilities or 121 equations to take derivitive of and check $f$ values?
You have 
$$\begin{Bmatrix} 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ \end{Bmatrix}
\begin{Bmatrix} 0 \\ 0 \\ 0 \\ 0 \\ x_5 \\ \end{Bmatrix}
\begin{Bmatrix} 0 \\ 0 \\ 0 \\ x_4 \\ 0 \\ \end{Bmatrix}...$$ 
However this can be avoided by considering the entire domain for example, if we were so lucky that it only had one derivative having a value of zero while simultaneously the second derivative being constant; there would be no need to check the boundaries. 
$\nabla (\nabla f \cdot  \mathbf v) \cdot \mathbf v= \nabla^2 f \Vert \mathbf v \Vert ^2$
Edit
After some thought you do not have to test each of the combinations of $x_i$ as those points lay on the individual curves/hyper surfaces intersecting $f$ and $x_i=0$. Therefore there are give additional equations each the intersection of 
$f(x_i)$ and $x_i=0$ for each $i$.
This gives each four equations and four unknowns. The max/min needs to be found and you proceed with the same procedures as before.
Simply compare these zeros with the earlier ones and select the max/ min respectively (throw away ones here less than zero).
Edit 2 
You actually do have to test the 120 or however many points as well. Sorry.
Edit 3
Should be $5+4+3+2+1+1=16$ funtions to minimize not 121.
