This is an example of the "difference of two squares" rule where (a^2-b) when expanded is the same as (a-b)(a+b) given that b is a square number. So, the same rule applies here - both terms in the original equation are squared, so you can expand it to (a-b)(a+b), with (x^2+x)^2 being a and (x-3)^2 being b.