The given differential equation is
cos2xdxdy+y=tanx
Dividing throughout by cos2x to make the coefficient of
dxdy unity,
dxdy+cos2xy=cos2xtanx
⇒dxdy+(sec2x)y=sec2xtanx
Linear Differential Equation
It is of the form
dxdy+Py=Q
Comparing,
P=sec2x,Q=sec2xtanx
Integrating Factor
∫Pdx=∫sec2xdx=tanx
I.F.=e∫Pdx=etanx
General Solution
y(I.F.)=∫Q(I.F.)dx+c
⇒yetanx=∫sec2xtanxetanxdx+c(i)
Substitution
Put
tanx=t
Differentiating,
sec2xdx=dt
Hence,
∫sec2xtanxetanxdx=∫tetdt
Applying Integration by Parts
∫tetdt=tet−∫1⋅etdt
=tet−et=(t−1)et
=(tanx−1)etanx
Substituting in (i)
yetanx=(tanx−1)etanx+c
Dividing every term by etanx,
y=(tanx−1)+ce−tanx
y=(tanx−1)+ce−tanx
which is the required general solution.