Solve $y'\cos x + y \sin x= x \sin 2x + x^2$ Given a differential equation as below
$$y'\cos x + y \sin x= x \sin 2x + x^2.$$
I need some tips on how to start solving. What do I have to determine?
Homogenity, linearity, or exactness?
 A: Writing your DE as $$y'+y\tan x=\frac{x\sin 2x+x^2}{\cos x},$$
the integrating factor is $$I=e^{\int\tan x dx}=\sec x$$
Therefore the solution is given by $$y\sec x=\int\frac{x\sin 2x+x^2}{\cos^2 x}dx$$
$$=\int2x\tan x+x^2\sec^2 x dx$$
$$\Rightarrow y\sec x=x^2\tan x+c$$
A: $$y(x)\sin(x)+y'(x)\cos(x)=x^2+x\sin(2x)\Longleftrightarrow$$
$$y'(x)+\tan(x)y(x)=x\sec(x)\left(x+\sin(2x)\right)\Longleftrightarrow$$

Let $\mu(x)=e^{\int\tan(x)\space\text{d}x}=\sec(x)$.
Multiply both sides by $\mu(x)$:

$$\sec(x)y'(x)+y(x)\left(\sec(x)\tan(x)\right)=x\sec^2(x)\left(x+\sin(2x)\right)\Longleftrightarrow$$

Substitute $\tan(x)\sec(x)=\frac{\text{d}\sec(x)}{\text{d}x}$:

$$\sec(x)y'(x)+y(x)\cdot\frac{\text{d}\sec(x)}{\text{d}x}=x\sec^2(x)\left(x+\sin(2x)\right)\Longleftrightarrow$$
$$\frac{\text{d}}{\text{d}x}\left(y(x)\sec(x)\right)=x\sec^2(x)\left(x+\sin(2x)\right)\Longleftrightarrow$$
$$\int\frac{\text{d}}{\text{d}x}\left(y(x)\sec(x)\right)\space\text{d}x=\int x\sec^2(x)\left(x+\sin(2x)\right)\space\text{d}x\Longleftrightarrow$$
$$\sec(x)y(x)=x^2\tan(x)+\text{C}\Longleftrightarrow$$

Divide both sides by $\mu(x)=\sec(x)$:

$$y(x)=x^2\sin(x)+\text{C}\cos(x)$$
