Hello I was trying to simplify and solve the following equation: $(x+y)^2 - y^2 - x^2 + 2xy$
My first approach was to factor the difference in squares leading to
$$(x+y)^2 - (y+x)(y-x) + 2xy $$
Then factor out $(x+y)$:$$(x+y)\cdot((x+y)-(y-x)) + 2xy$$
and then simplify: $$(x+y)\cdot(2x)+2xy = 2x^2 + 4xy$$
However, when actually expanding $(x+y)^2$ and then simplifying the result is only $4xy$:
$$x^2 + 2xy + y^2 - y^2 - x^2 + 2xy = 4xy$$
Why will those methods lead to two different equations? Did I break a rule of algebra? Normally I thought this should lead to an outcome that is equal. Is there any rule when simplification by expansion would be favored over factoring?
$$(x+y)^2 \color{green}{- y^2 - x^2} + 2xy=(x+y)^2 \color{red}{-(y+x)(y-x)} + 2xy \tag 1$$
It is a wrong claim, $$RHS{=(x+y)^2 - (y+x)(y-x) + 2xy\\ =(x+y)^2 - (y^2-x^2) + 2xy\\ =(x+y)^2 - y^2+x^2 + 2xy\ne LHS}$$
& $$\color{green}{- y^2 - x^2}\ne \color{red}{-(y+x)(y-x)}$$