How to solve the differential equation: \((x^2\cos x – y)dx + xdy = 0\)

hirophysics.com

Question:

Solve \((x^2\cos x – y)dx + xdy = 0\).

Answer:

Rewrite the equation as follows:

\[  \frac{dy}{dx}-\frac{y}{x}=-x\cos x  \]

When the right hand side is zero, the solution is \(y=Cx\). Using variation of constants, we make \(C\) as a function of \(x\). Namely, \(y=C(x)x\) and plug it in the above equation.

\[  \frac{d(C(x)x)}{dx}-\frac{C(x)x}{x}=-x\cos x  \]

\[ C'(x)x+C(x)-C(x)=-x\cos x  \]

\[ C'(x) = – \cos x  \]

\[ C(x) = – \sin x + C  \]

We know \(C(x)=\frac{y}{x}\), so

\[ \frac{y}{x} = – \sin x + C \]

\[ y = x(-\sin x + C)  \]