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.
 A: You can try $$x^4+2x^3y+3x^2y^2+2xy^3+y^4= x^2y^2({x^2\over y^2}+2{x\over y}+3+2{y\over x}+ {y^2\over x^2})$$
Let $t= {x\over y}+{y\over x}$ then we have ${x^2\over y^2}+{y^2\over x^2}=t^2-2$, so $$...= x^2y^2(t^2-2+2t+3) =x^2y^2(t+1)^2= $$ $$=x^2y^2({x\over y}+{y\over x}+1)^2 =(x^2+y^2+xy)^2$$
A: 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
A: Note,
$$\begin{array}
& & x^4+2x^3y+3x^2y^2+2xy^3+y^4 \\
& =( x^4+ 2x^2y^2+y^4 )+ 2x^3y+x^2y^2+2xy^3\\
&=( x^2+y^2)^2+ (2x^3y+2xy^3) + x^2y^2 \\
&=( x^2+y^2)^2+ 2xy(x^2+y^2) + (xy)^2 \\
&=(x^2+xy+y^2)^2
\end{array}$$
A: Writing $t=\frac xy$ (i.e., factoring out $y^4$), your expression is
$$
y^4(t^4 + 2t^3 + 3t^2 + 2t +1).
$$
Noticing the $1,2,3,2,1$ pattern within the parentheses, you might imagine arranging the terms in a square array:
$$
\begin{matrix}t^4&t^3&t^2\\ t^3&t^2&t\\t^2&t&1\end{matrix}$$
which leads you to recognize $(t^2+t+1)^2$.
A: When sorted by overall degree, you can notice the coefficients are symmetric, so that might indicate a remarkable identity.
$$x^4+2x^3y+3x^2y^2+2xy^3+y^4=(x^2+xy+y^2)^2$$ 
If we think about a squared expression, then since there is no $\sqrt{\cdot}$ involved it is interesting to look at even powers because these are potentially the $a,b,c$ you are searching for.
We have $\ x^4,\ x^2y^2\ $ and $\ y^4\ $ so we might start with $(x^2+k\,xy+y^2)^2$, with a coefficient $k$ for the middle term, since it is the only one we are not really sure of.
So you develop the expression are see what's left, in this case, with $k=1$ this is an equality so we are done.
A: In cases like $\,x^4+2x^3y+3x^2y^2+2xy^3+y^4\,$ where the difference between consecutive coefficients is "simpler" than the original sequence, it is worth trying to multiply by $\,x-y\,$:
$$
(x-y)(x^4+2x^3y+3x^2y^2+2xy^3+y^4) \,=\, x^5 + x^4 y + x^3 y^2 - x^2 y^3 - x y^4 - y^5
$$
The same pattern of "simpler" differences applies here, so multiplying by $\,x-y\,$ one more time:
$$
\begin{align}
(x-y)^2(x^4+2x^3y+3x^2y^2+2xy^3+y^4) \,&=\, (x-y)(x^5 + x^4 y + x^3 y^2 - x^2 y^3 - x y^4 - y^5)
\\ &=\, x^6 - 2 x^3 y^3 + y^6
\\ &=\, (x^3-y^3)^2
\\ &=\, (x-y)^2(x^2+xy+y^2)^2
\end{align}
$$
