<s>[INST] Can someone suggest a way to simplify $x_1(y_1 - x^Ty) + x_1(w_1 - x^Tw)^2 - x_1^2(w_1 - x^Tw)^2 + x_1x_2(w_1 - x^Tw)^2$ Let $x = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix}$, $y = \begin{bmatrix} y_1 \\ y_2 \end{bmatrix}$, $w =\begin{bmatrix} w_1 \\ w_2 \end{bmatrix}$
I have the following vector:

$V = \begin{bmatrix} x_1(y_1 - x^Ty) + x_1(w_1 - x^Tw)^2 - x_1^2(w_1 -
 x^Tw)^2 + x_1x_2(w_1 - x^Tw)^2 \\ x_2(y_2 - x^Ty) + x_2(w_2 - x^Tw)^2
 - x_2^2(w_2 - x^Tw)^2 + x_2x_1(w_2 - x^Tw)^2 \end{bmatrix}$

As you can see, the components has some interesting structures
I wish to put them into a much more compact form but I am not sure how to proceed
But I can do it for the first "part" in the above vector, consider $$V^* = \begin{bmatrix} x_1(y_1 - x^Ty)\\ x_2(y_2 - x^Ty)\end{bmatrix}$$
I can put this into $V^* = \text{Diag}(x)[y - x^Ty \mathbf{1}]$
Can something similar be done to $V$ itself?
 [/INST] $$B \begin{array}[t]{l} = \begin{bmatrix}  x_1(w_1 - \mathbf x^T\mathbf w)^2 - x_1^2(w_1 -
 \mathbf x^T\mathbf w)^2 + x_1x_2(w_1 - \mathbf x^T\mathbf w)^2 \\  x_2(w_2 - \mathbf x^T\mathbf w)^2
 - x_2^2(w_2 - \mathbf x^T\mathbf w)^2 + x_2x_1(w_2 - \mathbf x^T\mathbf w)^2 \end{bmatrix}
\\[3ex]
=\begin{bmatrix} (w_1 - \mathbf x^T \mathbf w)^2 & 0 \\ 0 & (w_2 - \mathbf x^T\mathbf w)^2 \end{bmatrix}\cdot\begin{bmatrix} x_1- x_1^2+x_1x_2 \\ x_2-x_2^2 + x_1x_2\end{bmatrix}
\\[3ex]
= \left[\operatorname{diag}(\mathbf w-\mathbf x^T \mathbf w\cdot \mathbf 1)\right]^2\cdot\begin{bmatrix} x_1 & 0\\0&x_2 \end{bmatrix}\cdot \begin{bmatrix} 1-x_1+x_2\\
1-x_2+x_1 \end{bmatrix}
\\[3ex]
=\left[\operatorname{diag}(\mathbf w-\mathbf x^T\mathbf w\cdot \mathbf 1)\right]^2\cdot\operatorname{diag}(\mathbf x)\cdot
\begin{bmatrix} 1-x_1+x_2\\
1-x_2+x_1 \end{bmatrix}
\\[3ex]
=\left[\operatorname{diag}(\mathbf w-\mathbf x^T\mathbf w\cdot \mathbf 1)\right]^2\cdot\operatorname{diag}(\mathbf x)\cdot\left(\mathbf 1-\mathbf x + \begin{bmatrix} 0 & 1\\ 1 & 0 \end{bmatrix}\cdot\mathbf x \right),
\end{array}$$
where $\mathbf 1 = \begin{bmatrix} 1\\1 \end{bmatrix}. $ Is this compact enough? The final answer will be $V = V^* + B$. 
</s>