Linear First-Order Equations

Integrating factors and the systematic approach

Beyond Separation

In previous chapters, we solved differential equations by separating variables: moving all the y terms to one side, all the x terms to the other, then integrating. This works beautifully when it works. But many equations resist separation.

Consider the equation y+2y=xy' + 2y = x. Try as you might, the y and x terms cannot be untangled. The right side mixes the variables in a way that prevents separation. We need a different approach.

The remarkable news is that there exists a method that solves every linear first-order equation. Not sometimes. Always. This method is algorithmic and systematic. Once you learn it, you can solve any equation of this type.

Interactive: Why Separation Fails

y+2y=xy' + 2y = x

This is a linear first-order equation. The slope field shows the direction of solutions at each point.

Notice how the slopes depend on both x and y. Can we solve this by separation of variables?

The key insight is this: if we cannot separate the equation, perhaps we can transform it into something we can integrate directly. We multiply both sides by a carefully chosen function that makes the left side become a perfect derivative. This function is called an integrating factor.

The Standard Form

Before applying the method, we must recognize what kind of equation we are dealing with. A linear first-order equation is one where yy and yy' appear only to the first power and are not multiplied together.

Every such equation can be written in standard form:

y+P(x)y=Q(x)y' + P(x)y = Q(x)

Here P(x)P(x) and Q(x)Q(x) are functions of xx only. The coefficient of yy' must be 1. If it is not, divide through to make it so.

Some examples:

  • y+2y=exy' + 2y = e^x has P(x)=2P(x) = 2 and Q(x)=exQ(x) = e^x
  • y1xy=x2y' - \frac{1}{x}y = x^2 has P(x)=1xP(x) = -\frac{1}{x} and Q(x)=x2Q(x) = x^2
  • xy+3y=sinxxy' + 3y = \sin x must first be divided by xx to get y+3xy=sinxxy' + \frac{3}{x}y = \frac{\sin x}{x}

The first step in applying our method is always to rewrite the equation in standard form. This makes P(x)P(x) and Q(x)Q(x) explicit, which is essential for the next step.

The Integrating Factor

Here is where the magic happens. We seek a function μ(x)\mu(x) such that when we multiply both sides of the equation by it, the left side becomes a perfect derivative.

Why would this help? Think about what we want. After multiplying by μ\mu, we get:

μy+μPy=μQ\mu y' + \mu P y = \mu Q

Now recall the product rule: ddx[μy]=μy+μy\frac{d}{dx}[\mu \cdot y] = \mu' y + \mu y'. If we could arrange for the left side to equal ddx[μy]\frac{d}{dx}[\mu y], we could integrate directly.

Interactive: Deriving the Integrating Factor

Step 1 of 7

Start with standard form

y+P(x)y=Q(x)y' + P(x)y = Q(x)

Every linear first-order equation can be written this way.

Comparing μy+μPy\mu y' + \mu P y with μy+μy\mu' y + \mu y', we see they match if μ=μP\mu' = \mu P. This is itself a separable equation for μ\mu! Separating and integrating:

dμμ=Pdx    lnμ=Pdx    μ=ePdx\frac{d\mu}{\mu} = P\,dx \implies \ln|\mu| = \int P\,dx \implies |\mu| = e^{\int P\,dx}

We can drop the absolute value and choose μ=eP(x)dx\mu = e^{\int P(x)dx} because any nonzero multiple of μ\mu works equally well (the constant factor cancels when we divide at the end).

This is the integrating factor. With it, the left side becomes exactly ddx[μy]\frac{d}{dx}[\mu y], and we can integrate:

μy=μQdx+C\mu y = \int \mu Q \, dx + C

Then we solve for yy by dividing through by μ(x)\mu(x).

The Method: A Five-Step Algorithm

Here is the complete procedure for solving any linear first-order equation y+P(x)y=Q(x)y' + P(x)y = Q(x):

Step 1: Standard form. Write the equation with the coefficient of yy' equal to 1. Identify P(x)P(x) and Q(x)Q(x).

Step 2: Compute the integrating factor. Calculate: μ(x)=eP(x)dx\mu(x) = e^{\int P(x)dx}

Step 3: Multiply. Multiply both sides by μ(x)\mu(x). Recognize that the left side becomes ddx[μy]\frac{d}{dx}[\mu y].

Step 4: Integrate. Integrate both sides: μ(x)y=μ(x)Q(x)dx+C\mu(x) y = \int \mu(x) Q(x) \, dx + C

Step 5: Solve for y. Divide by μ(x)\mu(x): y=1μ(x)(μ(x)Q(x)dx+C)y = \frac{1}{\mu(x)} \left( \int \mu(x) Q(x) \, dx + C \right)

Interactive: Practice the Method

The Equation

y+2y=1y' + 2y = 1

Standard form with P(x) = 2 and Q(x) = 1

Adjust coefficients to see how the solution changes. Click the dots to step through the method.

A practical note: when computing μ(x)=eP(x)dx\mu(x) = e^{\int P(x)dx}, you do not need to include a constant of integration. Any antiderivative works because adding a constant CC to the exponent would multiply μ\mu by eCe^C, which cancels when you divide at the end.

A Complete Example

Let us work through a full example with a non-constant coefficient. This will solidify the method.

Interactive: Worked Example

1 of 6

The Problem

Solve the initial value problem:

y+2xy=x2,y(1)=2y' + \frac{2}{x}y = x^2, \quad y(1) = 2

The example above solves y+2xy=x2y' + \frac{2}{x}y = x^2 with initial condition y(1)=2y(1) = 2. Notice how the integrating factor μ(x)=x2\mu(x) = x^2 arises naturally from integrating P(x)=2xP(x) = \frac{2}{x}:

2xdx=2lnx=ln(x2)    μ=eln(x2)=x2\int \frac{2}{x}dx = 2\ln|x| = \ln(x^2) \implies \mu = e^{\ln(x^2)} = x^2

After multiplying by x2x^2, the left side becomes ddx[x2y]\frac{d}{dx}[x^2 y], which is exactly what the product rule gives us: x2y+2xyx^2 y' + 2xy. This recognition is the heart of the method.

Visualizing Solutions

The solutions to linear first-order equations have a characteristic structure. The general solution contains two parts: a particular solution that satisfies the non-homogeneous equation, plus the general solution to the homogeneous equation (where Q = 0).

For y+Py=Qy' + Py = Q:

  • The homogeneous solution yh=CePdxy_h = Ce^{-\int P dx} decays or grows exponentially
  • The particular solution ypy_p depends on Q and may oscillate, grow, or approach a constant

Interactive: Solution Explorer

y+1.0y=1.0y' + 1.0y = 1.0
Forcing function Q(x):

P > 0: Solutions are attracted toward a particular solution (stable).

The blue curve is the solution through (0, 0.0). Gray curves show other solutions.

Adjust the parameters above to see how solutions behave. When P>0P > 0, the homogeneous part decays exponentially, and solutions approach the particular solution. When P<0P < 0, solutions diverge from it. The forcing function Q(x) determines what the solutions are attracted to or repelled from.

Why This Method Always Works

Unlike separation of variables, which only applies to certain special forms, the integrating factor method works for every linear first-order equation. This is a powerful guarantee.

The reason is structural. The operation of multiplying by μ\mu and recognizing a product derivative is always valid when μ=μP\mu' = \mu P. And since μ=ePdx\mu = e^{\int P dx} always satisfies this equation, the method never fails.

The integrals Pdx\int P dx and μQdx\int \mu Q dx might be difficult to compute in closed form. But that is a separate issue from whether the method applies. The method itself is universal.

Another Example: The Mixing Tank

Consider a practical application. A tank contains 100 liters of water with 10 kg of dissolved salt. Brine containing 0.5 kg of salt per liter flows in at 4 liters per minute, and the well-mixed solution flows out at the same rate. How much salt is in the tank at time tt?

Let y(t)y(t) be the amount of salt (in kg) at time tt minutes. Salt enters at rate 0.5×4=20.5 \times 4 = 2 kg/min. Salt leaves at rate y100×4=y25\frac{y}{100} \times 4 = \frac{y}{25} kg/min (concentration times flow rate).

The differential equation is:

dydt=2y25\frac{dy}{dt} = 2 - \frac{y}{25}

Rewriting in standard form: y+125y=2y' + \frac{1}{25}y = 2.

Here P(t)=125P(t) = \frac{1}{25} and Q(t)=2Q(t) = 2. The integrating factor is:

μ(t)=e125dt=et/25\mu(t) = e^{\int \frac{1}{25}dt} = e^{t/25}

Multiplying through and recognizing the product:

ddt[et/25y]=2et/25\frac{d}{dt}[e^{t/25} y] = 2e^{t/25}

Integrating: et/25y=50et/25+Ce^{t/25} y = 50e^{t/25} + C.

So y=50+Cet/25y = 50 + Ce^{-t/25}. With y(0)=10y(0) = 10, we get C=1050=40C = 10 - 50 = -40.

The solution is y(t)=5040et/25y(t) = 50 - 40e^{-t/25}. As tt \to \infty, the salt amount approaches 50 kg, the equilibrium level.

Handling Initial Value Problems

When given an initial condition y(x0)=y0y(x_0) = y_0, we use it to determine the constant CC in our general solution.

The process is straightforward: after finding the general solution y=1μ(x)(μQdx+C)y = \frac{1}{\mu(x)}\left(\int \mu Q\,dx + C\right), substitute x=x0x = x_0 and y=y0y = y_0, then solve for CC.

For instance, in the mixing tank example with y(0)=10y(0) = 10, we substituted into y=50+Cet/25y = 50 + Ce^{-t/25} to get 10=50+C10 = 50 + C, giving C=40C = -40.

There is also an elegant definite integral form:

y(x)=1μ(x)(y0μ(x0)+x0xμ(t)Q(t)dt)y(x) = \frac{1}{\mu(x)} \left( y_0 \mu(x_0) + \int_{x_0}^{x} \mu(t) Q(t) \, dt \right)

This formula automatically incorporates the initial condition. The first term accounts for the initial value, while the integral accumulates the effect of the forcing function QQ from the initial point onward.

Common Pitfalls

A few errors to avoid:

Forgetting standard form. If the coefficient of yy' is not 1, divide through first. The equation 2y+4y=62y' + 4y = 6 must become y+2y=3y' + 2y = 3 before identifying P(x)=2P(x) = 2. Otherwise, your integrating factor will be wrong.

Including a constant in the integrating factor. When computing Pdx\int P\,dx, any antiderivative works. Adding a constant just multiplies μ\mu by a constant factor, which cancels when you divide at the end. Keep it simple: use the simplest antiderivative.

Forgetting to divide by μ\mu. After integrating to get μy=\mu y = \ldots, you must divide by μ(x)\mu(x) to solve for yy. This step is easy to overlook.

Sign errors in P(x)P(x). Watch the sign when rewriting in standard form. In y3y=xy' - 3y = x, we have P(x)=3P(x) = -3, not +3+3.

Looking Ahead

Linear first-order equations are just the beginning. In the next chapter, we explore exact equations, where the differential equation is secretly the total derivative of some function F(x,y)F(x, y). The integrating factor method sometimes transforms non-exact equations into exact ones.

Later, we will see that second-order linear equations have a similar structure, but with more elaborate solutions involving characteristic equations and complementary functions. The integrating factor idea reappears in different guises throughout differential equations.

Key Takeaways

  • A linear first-order equation has the form y+P(x)y=Q(x)y' + P(x)y = Q(x), where yy and yy' appear linearly
  • The integrating factor μ(x)=eP(x)dx\mu(x) = e^{\int P(x)dx} is derived by requiring that the left side become a perfect derivative
  • After multiplying by μ\mu, we recognize ddx[μy]=μQ\frac{d}{dx}[\mu y] = \mu Q and integrate directly
  • This method always works for any linear first-order equation, unlike separation of variables
  • The general solution is y=1μ(μQdx+C)y = \frac{1}{\mu}\left(\int \mu Q \, dx + C\right)
  • For initial value problems, substitute the initial condition to determine CC
  • Always put the equation in standard form first, with the coefficient of yy' equal to 1