From teh answer in my textbook and the result given in wolframAlpha/Maple etc i know that this:

Simplifies to this:

But i don't see how they work out that is the factor to take out.

If there computer can work it out consistently im assuming theres a technique/method used to find it? Could anyone point me in the right direction?

Thank you