The first thing to notice here is that your function can be written as the sum of two other functions, let's say #g(x)# and #h(x)#, which means that you c an use the sum rule to differentiate it.
The sum rule tells you that the derivative of a sum of functions is equal to the sum of the derivatives of those functions
#color(blue)(d/dx(f(x)) = f^'(x) + g^'(x))#
In your case, you have
#f(x) = y = 1/2sin(2x) + cosx#, so that
#{ (g(x) = 1/2sin(2x)), (h(x) = cosx) :}#
The derivative of #f(x)# will thus loook like this
#y^' = d/dx(1/2 * sin(2x)) + d/dx(cosx)#
#y^' = 1/2 * d/dx(sin(2x)) + d/dx(cosx)#
At this stage, you need to realize that #g^'(x)# can be differentiate by using he chain rule and that
#d/dx(cosx) = -sinx#
#d/dx(sinx) = cosx#
So, the chain rule tells you that you can differentiate a function #y# that depends on a variable #u#, which in turn depends on another variable #x#, like this
#color(blue)(d/dx(y) = d/(du)(y) * d/dx(u))#
In your case, you have #g(x) = sinu#, where #u = 2x#. This means that you have
#d/dx(g(x)) = d/(du)(sinu) * d/dx(u)#
#d/dx(g(x)) = cosu * 2d/dx(x)#
This is equivalent to
#d/dx(g(x)) = cos(2x) * 2#
Your original derivative now becomes
#y^' = 1/color(red)(cancel(color(black)(2))) * (color(red)(cancel(color(black)(2))) * cos(2x)) + (-sinx)#
#y^' = color(green)(cos(2x) - sinx)#