# first order linear differential equation 2

I got the following equation: $$\cos{x}\cdot y'=y\sin {x} + \sin^2x$$.

Probably a fairly simple equation. I run into problems with the integrating factor.

I get: $$y'-y\tan x=\tan x\sin x$$

So $$g(x)=tan(x) \iff G(x)=-\ln|\cos x|+C$$.

So the integrating factor is $$e^{-ln|\cos x|} \iff \frac{1}{\cos x}$$.

If we multiply in the I.G into the equation we get: $$\frac{y'}{\cos x}-\frac{\sin x}{\cos^2x}y=\tan^2x$$.

It is here that I run into problems. The next step would be to put: $$D(\frac{y}{\cos x})=\tan^2x$$

But when I controll derivate I don't get my original expression but $$\frac{y'}{\cos x}+\frac{\sin x}{\cos^2x}y$$

(I lose the minus sign).

Any pointers to where I went wrong would be appreciated.

$$\cos{x}\cdot y'=y\sin {x} + \sin^2x$$ $$\cos{x}\cdot y'-y\sin {x} = \sin^2x$$ $$\left(y\cos x\right)'=\sin^2x$$ $$y\cos x=\int\sin^2x dx=\frac{x}{2}-\frac{\sin{ 2 x }}{4}+C$$ $$y=\frac{x}{2 \cos{x}}-\frac{\sin{x}}{2}+\frac{C}{\cos x}$$
For the integrating factor you want to compress the left side into the form $$(e^Gy)'=e^G(y'+gy).$$ Comparing with the existing coefficients gives $$g=-\tan x=\frac{-\sin x}{\cos x}=\frac{f'(x)}{f(x)},$$ so that $$G=\ln|f(x)|=\ln|\cos(x)|.$$ But the form of the ODE with $$\cos(x)y'(x)$$ in the leading term is already the original equation, thus compute again $$(\cos(x)\,y(x))'=\cos(x)y'(x)-\sin(x)y(x)=\sin^2x.$$