This type of exercise can be solved using the function : factor

Algebraic calculus is a form of calculus that combines letters, numbers, and operations.
The following formulas can be used in factoring and expanding algebraic expressions.

P is a polynomial, a a real. If P(a)=0, then P is factorizable by (x-a). That is, there exists a polynomial Q such that for all x, P(x)=(x-a)Q(x).

Reduction of a literal expression

To simplify a literal expression, we group the dependent terms depending on the same letters and then we reduce each grouping, as in this example:
x+x+3y-2y=2x+y.