Hey Paze.

The basic idea is that you cancel out terms when you have a common factor on both the numerator and the denominator. So as an example given (x^2 + 2x + 1)/(x+1), we get (x^2 + 2x + 1)/(x+1) = (x+1)(x+1)/(x+1) = (x+1).

Note that you can't do this if the factor is zero, so in the above case if x = -1, then you could not do the factorization (but the expression couldn't be evaluated anyway in that case).