To solve the differential equation given by x dy/dx + y = x² sin x, we first rewrite it in a more standard form. We can rearrange the equation as follows:
dy/dx = (x² sin x – y)/x.
This is a first-order linear differential equation. We can recognize it as dy/dx + (1/x)y = x sin x, which fits the standard form of a linear differential equation dy/dx + P(x)y = Q(x), with:
- P(x) = 1/x
- Q(x) = x sin x
Next, we need to find the integrating factor, which is given by:
μ(x) = e^{∫P(x) dx} = e^{∫1/x dx} = e^{ln|x|} = |x|.
For simplicity, we can consider μ(x) = x since we are working with x > 0.
We now multiply the entire differential equation by the integrating factor:
x dy/dx + y = x² sin x.
The left-hand side can be rewritten as the derivative of a product:
d/dx (xy) = x² sin x.
Next, we integrate both sides with respect to x:
∫d(xy) = ∫x² sin x dx.
To solve the right side, we can use integration by parts. Let:
- u = x², hence du = 2x dx
- dv = sin x dx, hence v = -cos x
Applying integration by parts:
∫x² sin x dx = -x² cos x – ∫(-cos x)(2x) dx.
This simplifies to:
∫x² sin x dx = -x² cos x + 2∫x cos x dx.
Again using integration by parts on ∫x cos x dx:
- u = x, hence du = dx
- dv = cos x dx, hence v = sin x
Thus, we find:
∫x cos x dx = x sin x – ∫sin x dx = x sin x + cos x.
Now substituting this back in:
∫x² sin x dx = -x² cos x + 2(x sin x + cos x).
Putting it all together, we have:
xy = -x² cos x + 2x sin x + 2cos x + C,
where C is the constant of integration.
Finally, we can isolate y:
y = -x cos x + 2 sin x + (2/x) cos x + C/x.
This gives us the general solution of the original differential equation:
y = -x cos x + 2 sin x + (2/x) cos x + C/x.