Formula use:
\left(a-b\right)^2=a^2-2ab+b^2
a^2-b^2=\left(a+b\right)\left(a-b\right)
Explanation
Given expression is: x^3-y^3-x\left(x^2-y^2\right)+y\left(x-y\right)^2
Factorize
x^3-y^3-x\left(x^2-y^2\right)+y\left(x-y\right)^2
\rightarrow x^3-y^3-x\left(x+y\right)\left(x-y\right)+y\left(x^2-2xy+y^2\right)
\rightarrow x^3-y^3-\left(x^2+xy\right)\left(x-y\right)+\left(x^2y-2xy^2+y^3\right)
\rightarrow x^3-y^3-\left(x^3+x^2y-x^2y-xy^2\right)+x^2y-2xy^2+y^3
\rightarrow x^3-y^3-x^3-x^2y+x^2y+xy^2+x^2y-2xy^2+y^3
\rightarrow x^2y-xy^2
\therefore xy\left(x-y\right)
Ans: xy\left(x-y\right)