<s>[INST] 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?
 [/INST] $$
\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}
$$
</s>