From the given linear differential equation, \(P(x)= \tan x\) and \(Q(x)=\sin2x.\)

Therefore, the integrating factor is given by

\({\left({x}\right)}={\int_{{0}}^{{x}}} \tan{{t}}{\left.{d}{t}\right.}={{\left[- \ln{ \cos{{t}}}\right]}_{{0}}^{{x}}}=- \ln{ \cos{{x}}}\).

So that, the solution is given by

\({y}={2} \cos{{x}}+ \cos{{x}}{\int_{{1}}^{{x}}}{\left( \cos{{t}}\right)}^{ -{{1}}} \sin{{2}}{t}{h}{t}\)

\(={2} \cos{{x}}+ \cos{{x}}{\int_{{1}}^{{x}}}{\left( \cos{{t}}\right)}^{ -{{1}}}{\left({2} \sin{{t}} \cos{{t}}\right)}{\left.{d}{t}\right.}\)

\(={2} \cos{{x}}+ \cos{{x}}{\int_{{1}}^{{x}}} \sin{{t}}{\left.{d}{t}\right.}\)

\(={2} \cos{{x}}+ \cos{{x}}{{\left[- \cos{{t}}\right]}_{{0}}^{{x}}}\)

\(={2} \cos{{x}}+ \cos{{x}}{\left({1}- \cos{{x}}\right)}\)

\(={4} \cos{{x}}-{2}{{\cos}^{2}{x}}\).

We can verify the function is the solution of the initial-value periblem since it satisfies the differential equation and the initial condition.