\(\left(x-y\right)^2+2\left(x^2-y^2\right)+\left(x+y\right)^2\)
\(=\left(x-y\right)^2+2\left(x-y\right)\left(x+y\right)+\left(x+y\right)^2\)
\(=\left[\left(x-y\right)+\left(x+y\right)\right]^2\)
\(=\left(x-y+x+y\right)^2\)
\(=\left(2x\right)^2\)
\(=4x^2\)
\(\left(x-y\right)^2+2\left(x^2-y^2\right)+\left(x+y\right)^2\)
\(=\left(x-y\right)^2+2\cdot\left(x-y\right)\left(x+y\right)+\left(x+y\right)^2\)
\(=\left(x-y+x+y\right)^2=\left(2x\right)^2=4x^2\)