Question:medium

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

Solution and Explanation

Step 1: Simplify the left side:
Open the bracket with the product rule: $\frac{d}{dx}(xy) = x y^{\prime} + y$.
Then $y + \frac{d}{dx}(xy) = x y^{\prime} + 2y$.
So the equation is $x y^{\prime} + 2y = x(\sin x + \log x)$.

Step 2: Make the left side a perfect derivative:
Multiply both sides by $x$.
\[ x^2 y^{\prime} + 2xy = x^2(\sin x + \log x) \]
The left side is exactly $\frac{d}{dx}\left(x^2 y\right)$, since $\frac{d}{dx}(x^2 y) = x^2 y^{\prime} + 2xy$.

Step 3: Integrate both sides:
\[ x^2 y = \int x^2\sin x\,dx + \int x^2\log x\,dx + C \]

Step 4: Evaluate the first integral:
Use the by-parts rule twice, with the polynomial as the first function.
\[ \int x^2\sin x\,dx = -x^2\cos x + 2x\sin x + 2\cos x \]
You can check this by differentiating: the derivative is $x^2\sin x$.

Step 5: Evaluate the second integral:
Take $u = \log x$ and $dv = x^2\,dx$, so $v = \frac{x^3}{3}$.
\[ \int x^2\log x\,dx = \frac{x^3\log x}{3} - \frac{1}{3}\int x^2\,dx = \frac{x^3\log x}{3} - \frac{x^3}{9} \]

Step 6: State the result:
\[ x^2 y = -x^2\cos x + 2x\sin x + 2\cos x + \frac{x^3}{3}\log x - \frac{x^3}{9} + C \]
Here $C$ is an arbitrary constant and $x > 0$.

Final Answer:
Solving for $y$ gives the general solution: \[ \boxed{y = -\cos x + \frac{2\sin x}{x} + \frac{2\cos x}{x^2} + \frac{x\log x}{3} - \frac{x}{9} + \frac{C}{x^2}} \]
Was this answer helpful?
0