for the first example shouldnt it be -2xcosx-2sinx+c as when you integrate -2cosx it would become +2sinx which then when you takeaway is -2sinx +c from the rest of the equation sorry if this is wrong maybe i didn't follow it through properly
When differentiating, it goes sin, cos, -sin, -cos. When integrating -cos, it goes to -sin. The full formula after integrating -cos was -2xcosx-(-2sinx)+c. Two negatives equal a positive. Therefore -2xcosx+2sinx+c is correct.