Linear differential equations
The form
dxdy+P(x)y=Q(x)
is a first-order linear differential equation in y. Linear here means y and dxdy appear to first power only , no y2, no siny. The functions P and Q depend only on x.
This is among the most useful DE forms in applied work , it models RC and RL circuits, mixing problems with constant flow, motion under linear drag, and many growth problems with constant input rates.
The integrating-factor idea
Suppose we multiply both sides by a function μ(x) , the integrating factor:
μ(x)dxdy+μ(x)P(x)y=μ(x)Q(x).
The left side resembles the derivative of a product dxd(μy)=μy′+μ′y, provided μ′=μP. Solving this for μ: μdμ=Pdx, so μ=e∫P(x)dx.
So the integrating factor is
μ(x)=e∫P(x)dx.
After multiplying, the equation becomes dxd(μy)=μQ, which integrates directly:
μ(x)y=∫μ(x)Q(x)dx+C,y=μ(x)1[∫μ(x)Q(x)dx+C].
The procedure
- Put the equation in standard form dxdy+P(x)y=Q(x) , coefficient of dxdy must be 1.
- Compute P(x) and the integrating factor μ(x)=e∫Pdx.
- Multiply both sides by μ.
- Recognise the left side as dxd[μy].
- Integrate both sides; solve for y.
When the roles swap: linear in x
Sometimes a DE is not linear in y but is linear in x. The form
dydx+P(y)x=Q(y)
is solved identically , treating x as the dependent variable and y as the independent variable. Integrating factor: μ(y)=e∫P(y)dy.
You should always test both forms when the obvious arrangement fails.
Worked examples
Example 1. Solve dxdy+y=ex.
Here P=1, Q=ex. μ=ex. Multiply: exy′+exy=e2x, i.e. (exy)′=e2x. Integrate: exy=2e2x+C, so y=2ex+Ce−x.
Example 2. Solve dxdy+xy=x2.
P=1/x, μ=e∫dx/x=eln∣x∣=∣x∣, take μ=x (positive branch). Multiply: xy′+y=x3, i.e. (xy)′=x3. Integrate: xy=4x4+C, so y=4x3+xC.
Example 3. Solve dxdy+ytanx=secx.
P=tanx, ∫tanxdx=ln∣secx∣, so μ=secx. Multiply: secx⋅y′+ysecxtanx=sec2x, i.e. (secx⋅y)′=sec2x. Integrate: secx⋅y=tanx+C, so y=sinx+Ccosx.
Example 4. Solve (x+y)dxdy=1.
Rewrite: dxdy=x+y1, then flip: dydx=x+y, i.e. dydx−x=y. Linear in x. P=−1, μ=e−y. Multiply: (e−yx)′=ye−y. Integrate (by parts): ∫ye−ydy=−ye−y−e−y+C. So e−yx=−ye−y−e−y+C, giving x=−y−1+Cey.
Example 5. Solve dxdy+2y=e3x, y(0)=1.
P=2, μ=e2x. Multiply: (e2xy)′=e5x. Integrate: e2xy=5e5x+C, so y=5e3x+Ce−2x. Apply IC: 1=51+C, so C=54. Particular: y=5e3x+4e−2x.
Example 6. Solve xdxdy−y=x2.
Divide by x: dxdy−xy=x. P=−1/x, μ=e−lnx=1/x. Multiply: x1dxdy−x2y=1, i.e. (xy)′=1. Integrate: xy=x+C, so y=x2+Cx.
Try it yourself
- dxdy+y=x
- dxdy+2xy=x
- dxdy−xy=2x2
- dxdy+ycotx=sin2x
- (1+x2)dxdy+2xy=4x2
- dxdy+y=cosx
- dxdy−ytanx=exsecx
- xdxdy+y=xcosx, y(π/2)=0.
- dydx+x=y (linear in x)
- (x+1)dxdy−y=ex(x+1)2
- dxdy−2y=x2e2x
- dxdy=xy−x (rearrange to standard form)
- dxdy−2ycot2x=1−2xcot2x−2csc2x
- Verify that for dxdy+Py=QP, the answer is y=Q+Ce−∫Pdx if Q is constant.
Pitfalls and tricks
- Always normalise to coefficient 1 on dxdy before computing P.
- μ=e∫Pdx. No constant of integration here , any antiderivative works (the constant just rescales μ).
- The product rule check. After multiplying by μ, the left side must equal (μy)′. Verify by expanding.
- Linear in x, not y? When the natural form has nonlinearity in y but linearity in x, swap roles and proceed.
- Don't forget +C when integrating μQ. It generates the family of solutions.