a) \(x^2-x-xy-2y^2+2y\)
\(=x^2-x-2xy+xy-2y^2+2y\)
\(=\left(-2y^2-2xy+2y\right)+\left(xy+x^2-x\right)\)
\(=2y\left(-y-x+1\right)+x\left(y+x-1\right)\)
\(=-2y\left(y+x-1\right)+x\left(y+x-1\right)\)
\(=\left(x-2y\right)\left(y+x-1\right)\)
b) \(x^2+4xy+2x+3y^2+6y\)
\(=x^2+3xy+xy+2x+3y^2+6y\)
\(=\left(3y^2+3xy+6y\right)+\left(xy+x^2+2x\right)\)
\(=3y\left(y+x+2\right)+x\left(y+x+2\right)\)
\(=\left(3y+x\right)\left(y+x+2\right)\)