Guides / Differential equations

Linear differential equations: standard form, the integrating factor, then integrate both sides

A first-order linear equation, y′ + P(x)y = Q(x), usually can't be separated, because the right side is a sum rather than a product. It can always be solved another way: multiply by an integrating factor that turns the left side into the derivative of a product, and integrate. The mistakes are in the setup and the bookkeeping: the form the equation is in, which side gets multiplied, and when the constant goes in.

Short answer

Get the equation into standard form y′ + P(x)y = Q(x), with nothing in front of y′. The integrating factor is μ = e∫P dx, with P's sign included. Multiply both sides by μ, and the left side becomes (μy)′. Integrate: μy = ∫ μQ dx + C, with the constant added before you divide by μ. Then y = 1μ(∫ μQ dx + C), and the initial condition fixes C.

Why it works

The product rule gives (μy)′ = μy′ + μ′y. Multiplying the equation by μ gives μy′ + μPy on the left, and that matches the product rule exactly when μ′ = μP. That is a separable equation for μ, and μ = e∫P dx solves it. Any antiderivative of P will do, so you can leave the constant out of μ.

Once the left side is (μy)′, the equation says (μy)′ = μQ, and integrating both sides is ordinary integration. The constant belongs to that integral, so it gets divided by μ along with everything else. That's why the solution is always a particular solution plus C/μ, never plus a bare C.

Example 1: a constant on the right

Solve y′ + 3y = 6 with y(0) = 0.

  1. P = 3, μ = e3xAlready in standard form.
  2. (e3xy)′ = 6e3xMultiply both sides by μ. The left side is the derivative of the product.
  3. e3xy = 2e3x + CIntegrate both sides, and add the constant now.
  4. y = 2 + Ce−3x, y(0) = 2 + C = 0, so y = 2 − 2e−3xCheck: y′ = 6e^(−3x), and y′ + 3y = 6e^(−3x) + 6 − 6e^(−3x) = 6. y rises toward 2.

Example 2: a negative P

Solve y′ − 2y = ex with y(0) = 0.

  1. P = −2, μ = e−2xP includes its sign.
  2. (e−2xy)′ = ex · e−2x = e−xBoth sides multiplied.
  3. e−2xy = −e−x + CThe constant goes in here.
  4. y = −ex + Ce2x, y(0) = −1 + C = 0, so y = e2x − exDividing by e^(−2x) is multiplying by e^(2x), so C becomes Ce^(2x). Check: y′ − 2y = 2e^(2x) − e^x − 2e^(2x) + 2e^x = e^x.

Example 3: standard form first

Solve xy′ − y = x3 for x > 0, with y(1) = 1.

  1. y′ − 1xy = x2Divide every term by x, so that y′ stands alone. Now P = −1/x.
  2. μ = e−ln x = 1x∫ −1/x dx = −ln x, and e^(−ln x) = 1/x for x > 0.
  3. (yx)′ = x, so yx = x22 + CThe right side is x² · 1/x.
  4. y = x32 + Cx, y(1) = 12 + C = 1, so y = x3 + x2Check in the original: y′ = (3x² + 1)/2, so xy′ − y = (3x³ + x − x³ − x)/2 = x³.

Example 4: a drug drip

A drug is given by IV at 10 mg per hour, and the body clears it at a rate of 0.5 times the amount present. Starting from none, find the amount A(t), its value after 4 hours, and the level it settles at.

  1. A′ = 10 − 0.5A, so A′ + 0.5A = 10, A(0) = 0Rate in minus rate out, then standard form.
  2. (et/2A)′ = 10et/2, so et/2A = 20et/2 + Cμ = e^(t/2), and ∫ 10e^(t/2) dt = 20e^(t/2).
  3. A = 20 + Ce−t/2, A(0) = 0 gives C = −20The constant was added before dividing, so it carries e^(−t/2).
  4. A(t) = 20(1 − e−t/2), A(4) = 20(1 − e−2) ≈ 17.29 mgAs t → ∞, A → 20 mg: the level where clearance, 0.5 × 20, matches the drip of 10 mg per hour.

Common mistakes, and the exact line they happen on

1. Finding μ before the equation is in standard form

The equation from Example 3.

  1. xy′ − y = x3Right so far.
  2. P = −1, μ = e−x, so (e−xy)′ = x3e−xThis is the mistake. P is the coefficient of y only after y′ stands alone. Multiplying by e^(−x) gives xe^(−x)y′ − e^(−x)y on the left, but (e^(−x)y)′ is e^(−x)y′ − e^(−x)y: the x in front of y′ doesn't fit. Divide by x first, and P = −1/x.

2. Multiplying only the left side by μ

The equation from Example 1.

  1. μ = e3xRight so far.
  2. (e3xy)′ = 6, so e3xy = 6x + C and y = 6xe−3xThis is the mistake. The left side was multiplied by e^(3x), but the 6 on the right was not. Check: this y gives y′ + 3y = 6e^(−3x), which is about 0.299 at x = 1, not 6. With both sides multiplied, the right side is 6e^(3x), and y = 2 − 2e^(−3x).

3. Adding the constant after dividing by μ

The equation from Example 2.

  1. e−2xy = −e−xIntegrated, but with the constant left for later.
  2. y = −ex + C, and y(0) = 0 gives y = 1 − exThis is the mistake. Check it: y′ − 2y = −e^x − 2 + 2e^x = e^x − 2, not e^x. The constant belongs on the line before, where dividing by e^(−2x) turns it into Ce^(2x), and the solution is y = e^(2x) − e^x.

Practice

  1. Solve y′ + y = 3 with y(0) = 0.

    Show answer

    μ = ex, exy = 3ex + C, so y = 3 − 3e−x.

  2. Solve y′ + 2y = 4e2x with y(0) = 1.

    Show answer

    (e2xy)′ = 4e4x, so e2xy = e4x + C and y = e2x + Ce−2x. y(0) = 1 gives C = 0: y = e2x.

  3. Solve y′ + yx = 3x for x > 0, with y(1) = 2.

    Show answer

    μ = eln x = x, (xy)′ = 3x2, xy = x3 + 1, so y = x2 + 1x.

  4. Solve y′ + y = x + 1 with y(0) = 2.

    Show answer

    (exy)′ = (x + 1)ex, and by parts ∫ (x + 1)ex dx = xex + C. So y = x + Ce−x and y = x + 2e−x.

  5. Coffee at 90 °C cools in a 20 °C room by T′ = −0.1(T − 20), with t in minutes. Find its temperature after 10 minutes.

    Show answer

    T′ + 0.1T = 2 gives T = 20 + Ce−0.1t and C = 70, so T(10) = 20 + 70e−1 ≈ 45.8 °C.