Linear differential equation In this linear differential equation, should I eliminate the $\tan x$ in the expression in order to get $\frac yx$ or may I cancel $\tan x$ by $\tan^2x$?
$$\frac{dy}{dx} = \tan x y + \cos x$$
 A: No,you shouldn't do that. 
Instead of doing so, use the below method in which we can find the solution of this differential equation without eliminating $tanx$.
The given equation is a linear differential equation of the first order, so we can solve it by using an integrating factor. 
The given equation is,
$\frac{dy}{dx} = tanx y + cosx$ 
$\frac{dy}{dx} + (-tanx) y = cosx.....(1)$ 
Standard form of linear differential equation is,
$\frac{dy}{dx} + P(x)y = Q(x)...(2)$
On comparing equation (1) and(2) we get, 
P(x)= -tanx and Q(x) = cosx
Solution of linear differential equation is,
$y \times I.F. = \int Q(x)\times I.F. dx .....(3)$
Now, we find the value of I.F.(Integrating factor),
$I.F. = e^{\int P(x)dx} = e^{\int (-tanx)dx} = e^{logcosx} = cosx$
Put the value of I.F. in equation(3)
${y}\times {cosx} = \int\big[{cosx}\times{cosx}dx\big] =\int cos^{2}x dx$
Use $cos2x = 2cos^2{x} - 1 \Rightarrow cos^2{x} = \frac{cos2x+1}{2}$
${y}\times {cosx}= \frac{1}{2}\int{(cos2x + 1)}dx= \frac{1}{2}\big[\frac{sin2x}{2} + x + C \big]$
here, C is an integration constant.
$y = \frac{2sinxcosx}{4cosx}+\frac{x}{2cosx} + \frac{C}{2cosx}$
$y = \frac{1}{2}\big[sinx+\frac{x}{cosx}+\frac{C}{cosx}\big]$
This is the solution of the given differential equation.
A: Starting from $y'(x) -\tan (x)\, y=\cos x$, and using the integrating factor 
$$\mu(x) =\cos x$$
we can write
$$(\cos x y(x))'=\cos^2x$$
Integrating directly reveals that 
$$y(x)=\left(\frac12x+a\right)\sec x+\frac12 \sin x$$
where $a$ is a constant of integration.
If $y(x_0)=y_0$, $x_0\ne (2n+1) \pi/2$, is given, then $a=(y_0-\frac12\sin(x_0))\cos x_0 -\frac12 x_0$. 
