Question
Solve the differential equation dxdy+xy=x2, given y(1)=2.
Solution — Step by Step
This is a linear first-order ODE in standard form dxdy+P(x)y=Q(x) with P(x)=1/x and Q(x)=x2.
μ(x)=e∫Pdx=e∫(1/x)dx=eln∣x∣=x(taking x>0)
xdxdy+y=x3⟹dxd(xy)=x3
The left side is exactly the derivative of xy — that is the whole purpose of the integrating factor.
xy=∫x3dx=4x4+C
So y=4x3+xC.
At x=1, y=2:
2=41+C⟹C=47
y=4x3+4x7
Why This Works
The integrating factor μ(x) is constructed so that multiplying the ODE by μ makes the left side exactly d(μy)/dx. After that, both sides can be integrated directly.
The choice μ=e∫Pdx is forced by the product rule: we need μ′=μP, which is exactly the differential equation μ itself satisfies.
Alternative Method
For this particular equation, we can also use the substitution v=xy (since the structure suggests it). Then dv/dx=y+xdy/dx=y+x(x2−y/x)=x3. Integrating gives v=x4/4+C, so xy=x4/4+C. Same answer faster.
Common Mistake
Forgetting the constant of integration C before applying the initial condition. If you write xy=x4/4 and plug in y(1)=2, you get 2=1/4 — a contradiction. Always carry C through the integration step, then solve for it.