I ran into this issue with a trig identity, but the part I'm curious about is really just algebra, so I hope this is the right place for it.

At any rate, after doing the appropriate calculations I ended up with a formula of

the book, however, lists the answer as

The two are equivalent, I'm just curious as to the mechanism of converting from one to the other. Can someone explain it to me, if possible?