How do I get from $x^4+2x^3y+3x^2y^2+2xy^3+y^4$ to $(x^2+xy+y^2)^2$? I was doing an example $$(x+y)^4+x^4+y^4$$ and I need to factor it. I've tried and couldn't really do much, so I checked if there was anything to help, and I came across a post asking about the same thing. But my question is how do I know that $$x^4+2x^3y+3x^2y^2+2xy^3+y^4=(x^2+xy+y^2)^2$$ without knowing the answer.
I know about $$(a+b+c)^2$$ but then how would i chose my $a, b$ and $c$?
There are many $xy$ combinations here, with different powers, so would I chose the lowest as my $b$, and $x^2$ as my $a$ and $y^2$ as my $c$, or perhaps is there another formula that can help me.

The given quartic form can be written as follows
$$q (x,y) := x^4+2x^3y+3x^2y^2+2xy^3+y^4 = \begin{bmatrix} x^2\\ x y\\ y^2\end{bmatrix}^\top \begin{bmatrix} 1 & 1 & t\\ 1 & 3-2t & 1\\ t & 1 & 1\end{bmatrix} \begin{bmatrix} x^2\\ x y\\ y^2\end{bmatrix}$$
Choosing $t = 1$, we obtain a symmetric, positive semidefinite, rank-$1$ matrix, namely, ${\bf 1}_3 {\bf 1}_3^\top$. Hence, we obtain the following (single term) sum of squares (SOS) decomposition
$$q (x,y) = \begin{bmatrix} x^2\\ x y\\ y^2\end{bmatrix}^\top \begin{bmatrix} 1\\ 1\\ 1\end{bmatrix} \begin{bmatrix} 1\\ 1\\ 1\end{bmatrix}^\top \begin{bmatrix} x^2\\ x y\\ y^2\end{bmatrix} = \color{blue}{\left( x^2 + x y + y^2 \right)^2}$$

factoring polynomials matrices rank-1-matrices
