I'm working from a book at the moment and in it there is a problem where you have to multiply two fractions. I don't need to show you the whole sum but there is a part of it that has $\displaystyle (a^4-b^4)$ and in order to diagonal cancel the fraction down you needed to know that you can change that to $\displaystyle (a^2+b^2)(a^2-b^2)$. But i don't know the rule that lets you do that.

I know that$\displaystyle (a^2-b^2)=(a+b)(a-b)$ but i still didn't know i could just apply it like that. Is there a rule or formula i can use that can solve things like this in the future?