x^3y-2x^2y^2+xy^3
=(x^3y-x^2y^2)+(xy^3-x^2y^2)
=x^2y(x-y)+xy^2(y-x)
=(x-y)(x^2y-xy^2)
=(x-y)xy(x-y)
=2