I'm not 100% sure, but I think the question just puts in a +2 by taking 2 away from the 1 in the quadratic.
- So you have the initial cos(x)^2 + 2 sin(x)
- This becomes 1 - sin(x)^2 + 2 sin(x) after applying the trig identity
- Then you put in the 2 at the front by taking away 2 from the 1 you have from above which gives you 2 + (-1) - sin(x)^2 + 2 sin(x)
- If you keep the 2 outside and add in a (-), you end up with 2 - (1 + sin(x)^2 - 2 sin(x)) as taking a (-) out swaps the sign for everything in the bracket
- You have a normal quadratic in the bracket which looks like b^2 - 2b + 1 which factorises into (b-1)^2 where I used b as a substitute for sin(x)
- You put this now factorised quadratic back into the equation to give yourself 2 - (sin(x) - 1)^2 like shown in the question
That's the method I would use. Again, I'm not sure if it's right though since the 2 at the front out of nowhere is kind of throwing me, and I'm guessing this is how it'd be done.