Find the minimum of the function $f(x_1,x_2) = (x_1 + x_2 + 3)^2 + (3x_1 + x_2 - 1)^2 + (2x_1 + x_2 + 1)^2$ Find the minimum of the function $f(x_1,x_2) = (x_1 + x_2 + 3)^2 + (3x_1 + x_2 - 1)^2 + (2x_1 + x_2 + 1)^2$.
We've been instructed to solve this by writing $f(x_1,x_2)$ as $||Ax - b||^2$, and $x = [x_1,x_2]^T$.
I'm not quite sure how to solve this, this is $Ax - b$ in my opinion:
$
        \begin{pmatrix}
        1 & 1  \\
        3 & 1  \\
        2 & 1 \\
        \end{pmatrix}
$
$(x_1,x_2)
^T -  (-3,-1,1)$
How do I continue from here?
 A: You are told to minimize $\|Ax-b\|^2$ for
$$[A]:=\left[\matrix{1&1\cr 3&1\cr 2&1\cr}\right],\qquad b=(-3,1,-1)^\top\ .$$Now
$$A:\quad {\mathbb R}^2\to{\mathbb R}^3,\qquad x\mapsto Ax$$
is the parametric representation of a $2$-plane $\pi$  in ${\mathbb R}^3$. This plane is spanned by the column vectors $a_1=(1,3,2)^\top$ and $a_2=(1,1,1)^\top$ of $[A]$, and its normal  computes to $$n=a_1\times a_2=(1,1,-2)^\top\ .$$ The point in $p\in \pi$ nearest to $b$ is characterized by the condition $b-p\perp \pi$, or $b-p=\lambda n$ for some $\lambda\in {\mathbb R}$. Since $p=Ax=x_1a_1+x_2 a_2$ for some unknown $x_1$, $x_2$ we now have to solve the $3\times3$ linear system 
$$x_1 a_1+x_2 a_2 +\lambda n= b$$
for $x_1$, $x_2$ (and $\lambda)$. The computation gives $x_1=2$, $x_2=-5$ (and $\lambda=0$, by accident). For this $x$ we have $$f(x)=\|Ax-b\|^2=\|p-b\|^2=\|\lambda n\|^2=0\ .$$
A: Some alternative solution, which I think it's a lot easier.
Notice that we add non - negative terms. This means that $f(x_1,x_2)\ge 0 ,\forall x_1,x_2 \in \mathbb R.$
Solving the system :
$$\left.\begin{array}{l}
x_1+x_2+3= 0\\
3x_1+x_2 - 1 =0
\end{array}
\right\}\implies x_1=2, x_2 = -5
$$
We also observe that for these values the third parenthesis becomes $2x_1+x_2+1=2\cdot 2-5+1=0$
Thus, for $(x_1,x_2) = (2,-5)$ we have that $f$ attains its minimum value, which is zero.

Taking for granted that the minimum value of $f$ is zero, then writing $f$ in the suggested form implies that $ \|Ax-b\|^2 = 0\iff Ax - b = 0 \iff Ax = b$. So, it sufficient to solve the system $Ax = b$.
A: I would find the critical point(s), then see what information the Hessian matrix provides.
\begin{equation}
\partial_{x_1} f = 7x_1 + 3x_2 + 1 = 0,
\end{equation}
and 
\begin{equation}
\partial_{x_2} f = 2x_1 + x_2 + 1 = 0,
\end{equation}
Solve this system to find that the critical point is at $(2,-5).$ 
The Hessian is 
\begin{equation}
H = \begin{pmatrix}
\partial_{x_1 x_1} f & \partial_{x_1 x_2} f\\ \partial_{x_2 x_1} f & \partial_{x_2 x_2} f
\end{pmatrix} =
\begin{pmatrix}
38 & 12 \\ 12  & 6 
\end{pmatrix}
\end{equation}
Since all leading minors are positive, we know that the critical point must be a minimum.  Thus, the minimum of the function is $m = f(2,-5).$
A: $$
\begin{align}
&\nabla\left[(x_1+x_2+3)^2+(3x_1+x_2-1)^2+(2x_1+x_2+1)^2\right]\\
&=2(x_1+x_2+3)\begin{bmatrix}1\\1\end{bmatrix}
+2(3x_1+x_2-1)\begin{bmatrix}3\\1\end{bmatrix}
+2(2x_1+x_2+1)\begin{bmatrix}2\\1\end{bmatrix}\\
&=\begin{bmatrix}28x_1+12x_2+4\\12x_1+6x_2+6\end{bmatrix}
\end{align}
$$
This vanishes when $x_1=2$ and $x_2=-5$. Plugging this point into the function gives
$$
0^2+0^2+0^2=0
$$
Knowing this, we can write
$$
\begin{align}
&(x_1+x_2+3)^2+(3x_1+x_2-1)^2+(2x_1+x_2+1)^2\\
&=((x_1-2)+(x_2+5))^2+(3(x_1-2)+(x_2+5))^2+(2(x_1-2)+(x_2+5))^2\\
&=14(x_1-2)^2+12(x_1-2)(x_2+5)+3(x_2+5)^2\\
&=2(x_1-2)^2+3(2(x_1-2)+(x_2+5))^2\\
\end{align}
$$
