Question:

Solve the differential equation \( y + \frac{d}{dx}(xy) = x(\sin x + \log x) \).

Show Hint

Expand \(\frac{d}{dx}(xy)\) to get \(\frac{dy}{dx} + \frac{2}{x}y = \sin x + \log x\), then multiply by the integrating factor \(x^2\) and integrate by parts.
Updated On: Oct 22, 2026
Show Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Step 1: Expand and write in standard form:
By the product rule, \(\frac{d}{dx}(xy) = x\frac{dy}{dx} + y\).
The equation becomes \(y + x\frac{dy}{dx} + y = x(\sin x + \log x)\).
\[ x\frac{dy}{dx} + 2y = x(\sin x + \log x) \]
Divide by \(x\) (the term \(\log x\) needs \(x > 0\)):
\[ \frac{dy}{dx} + \frac{2}{x}\,y = \sin x + \log x \]
This is a linear equation \(\frac{dy}{dx} + Py = Q\) with \(P = \frac{2}{x}\) and \(Q = \sin x + \log x\).

Step 2: Find the integrating factor:
\[ \text{I.F.} = e^{\int P\,dx} = e^{2\log x} = x^2 \]

Step 3: Write the general solution:
\[ y \cdot x^2 = \int x^2(\sin x + \log x)\,dx + C \]

Step 4: Integrate \(x^2 \sin x\) by parts:
\[ \int x^2\sin x\,dx = -x^2\cos x + 2\int x\cos x\,dx \]
\[ \int x\cos x\,dx = x\sin x + \cos x \]
\[ \int x^2\sin x\,dx = -x^2\cos x + 2x\sin x + 2\cos x \]

Step 5: Integrate \(x^2 \log x\) by parts:
Take \(\log x\) as the first function and \(x^2\) as the second.
\[ \int x^2\log x\,dx = \frac{x^3}{3}\log x - \int \frac{x^3}{3}\cdot\frac{1}{x}\,dx = \frac{x^3}{3}\log x - \frac{x^3}{9} \]

Step 6: Put the pieces together:
\[ x^2 y = -x^2\cos x + 2x\sin x + 2\cos x + \frac{x^3}{3}\log x - \frac{x^3}{9} + C \]
Divide by \(x^2\):
\[ y = -\cos x + \frac{2\sin x}{x} + \frac{2\cos x}{x^2} + \frac{x}{3}\log x - \frac{x}{9} + \frac{C}{x^2} \]

Final Answer:
The general solution, for \(x > 0\), is \[ \boxed{x^2 y = -x^2\cos x + 2x\sin x + 2\cos x + \frac{x^3}{3}\log x - \frac{x^3}{9} + C} \]
Was this answer helpful?
0
0