\(\def\ans#1{\bbox[border:1px solid green,6pt]{#1}}\)

First-Order Linear Differential Equations

The following are some examples of first-order linear differential equations (FOLDE):

  1. \(y'+\dfrac{1}{x}y=2\)

  2. \(y' + 3x^2y = 6x^2\)

  3. \(y' + 2y = 2e^x\)

  4. \(xy'-2y=x^2\)

The general form is \[y'+P(x)y = Q(x),\] where \(P(x)\) and \(Q(x)\) are continuous, but not necessarily linear. These are called linear differential equations because they are linear with respect to \(y\), meaning that they can be written in precisely this form. Notice that the last example above isn't in this form, but it can be easily rewritten in the proper form by dividing each term by \(x\).

Procedure

First, we'll work through the first example above, skimming over some details. Once we've seen a full problem worked out, it will be easier to go back and fill in those details. We begin, then, with the following differential equation: \[y'+\dfrac{1}{x}y=2.\] Without explaining why (this is what we'll come back to), I'll multiply every term in the equation by \(x\); this is what we call the integrating factor, because it will help us get to a point where we can solve by integrating. After doing this, we have \[xy' + y = 2x.\] How does this help? Notice that the left-hand side is equal to \((xy)'\) (check this using the Product Rule). We'll see this in the other examples we do, but once we know what the integrating factor is, multiplying it on both sides will always make the left-hand side (assuming we've written the diff eq in standard FOLDE form) equal to the derivative of the integrating factor times \(y\). In any case, now we have \[(xy)' = 2x,\] which we can integrate with respect to \(x\) in order to undo the derivative. \[xy = \int 2x \ dx = x^2 + C\] Finally, to solve for \(y\), simply divide by \(x\): \[\ans{y=x+\dfrac{C}{x}}\]

Integrating Factor: \(I = e^{\ \int P(x) \ dx}\)

The one point that we didn't see in detail was where the integrating factor came from in that example. The integrating factor can always be found by first writing the FOLDE in its standard form: \[y' + P(x)y = Q(x),\] in which case the integrating factor is \[I(x) = e^{\int P(x) \ dx}.\]

Why?

To be honest, you can skip this section and go on to the examples if you like; as long as you memorize how to find the integrating factor, you don't need to worry about where it came from. I believe in being thorough, though, and showing that nothing in math comes out of the blue.

To see where \(I(x)\) came from, think about what we wanted: we wanted the left-hand side to collapse to \((I(x)y)'\), so we want \[I(x)[y' + P(x)y] = [I(x)y]'.\] Let's start from here and simplify things until it becomes clear what \(I(x)\) must be.

\[\begin{align} I(x)y' + I(x)P(x)y &= I(x)y' + I'(x)y\\ I(x)P(x)y &= I'(x)y\\ I(x)P(x) &= I'(x)\\ &\text{(a separable equation in terms of } I \text{)}\\ I(x)P(x) &= \dfrac{dI}{dx}\\ P(x) \ dx &= \dfrac{1}{I} \ dI\\ \int P(x) \ dx &= \int \dfrac{1}{I} \ dI\\ \int P(x) \ dx &= \ln I\\ I &= e^{\int P(x) \ dx} \end{align}\]

Examples

Solve the following differential equation. \[y'+3x^2y = 6x^2\]

Solution

This one's already written in standard form, so it is clear that \(P(x) = 3x^2\), which means that \[I(x) = e^{\int 3x^2 \ dx} = e^{x^3}.\] Once we multiply that by every term, we get the following (noting that the left-hand side collapses as always): \[\left(e^{x^3}y\right)' = 6x^2e^{x^3}\]

To integrate, use u-substitution (not shown fully here, but you can verify the details). \[e^{x^3}y = \int 6x^2e^{x^3} \ dx = 2e^{x^3} + C\]

Finally, solve for \(y\) by dividing both sides by \(e^{x^3}\): \[\ans{y = 2 + Ce^{-x^3}}\]

Try it yourself:

(click on the problem to show/hide the answer)

Solve the following differential equation. \[y'+2y=2e^x\]
\(\dfrac{2}{3}e^x+Ce^{-2x}\)

Solve the following differential equation. \[xy'-2y = x^2\]

Solution

This one is not written in standard form, so we must do that before picking out \(P(x)\) in order to find \(I(x)\). \[y' - \dfrac{2}{x}y = x\] \[P(x) = -\dfrac{2}{x} \longrightarrow I(x) = e^{\int -2/x \ dx} = e^{-2\ln x}\] To simplify \(I(x)\) further, you must remember your log rules: remember that a constant in front of a logarithm can be moved to the exponent inside the logarithm: \[I(x) = e^{-2\ln x} = e^{\ln x^{-2}} = x^{-2} = \dfrac{1}{x^2}.\]

After multiplying the integrating factor through the equation, we get the following: \[\left(\dfrac{1}{x^2}y\right)' = \dfrac{1}{x},\] which we can integrate. \[\dfrac{1}{x^2}y = \ln x + C \longrightarrow \ans{y = x^2 \ln x + Cx^2}\]

Solve the following differential equation. \[xy'+y = \sqrt{x}\]

Solution

With this one, too, we have to start by writing it in standard form: \[y' + \dfrac{1}{x}y = \dfrac{\sqrt{x}}{x}\] \[P(x) = \dfrac{1}{x} \longrightarrow I(x) = e^{\int 1/x \ dx} = e^{\ln x} = x\]

After multiplying the integrating factor through, we get \[(xy)' = \sqrt{x},\] and after integrating, we find that \[xy = \int \sqrt{x} \ dx = \dfrac{2}{3}x^{3/2} + C \longrightarrow \ans{y = \dfrac{2}{3}\sqrt{x} + \dfrac{C}{x}.}\]

Try it yourself:

(click on the problem to show/hide the answer)

Solve the following differential equation. \[y'=x+5y\]
\(-\dfrac{1}{5}x-\dfrac{1}{25}+Ce^{5x}\)

Mixing Problem Example

A tank initially contains 1000 L of pure water. There are two pipes that bring brine into the tank: one stream contains 0.1 kg of salt per liter of water and enters the tank at a rate of 10 L/min, and the other contains 0.2 kg of salt per liter of water and enters the tank at a rate of 5 L/min. The solution in the tank is kept thoroughly mixed and drains from the tank at 10 L/min. Find a solution for \(y(t)\), the amount of salt in the tank after \(t\) minutes.

Solution

This mixing problem is different from the one in the last section; all three differences that I pointed out after doing that problem are present here. Remember, though, the only one that really changes the problem is the fact that the inlet and outlet flowrates are different. This means that instead of the concentration of salt in the tank being \[\dfrac{y}{1000},\] it is \[\dfrac{y}{1000+5t}.\] Again, \[\begin{align} \dfrac{dy}{dt} &= \text{rate in } - \text{ rate out}\\ \dfrac{dy}{dt} &= (0.1)(10) + (0.2)(5) - \dfrac{y}{1000+5t} \cdot 10\\ \dfrac{dy}{dt} &= 2-\dfrac{2y}{200+t} \end{align}\]

Note that this one is not separable, specifically because of that \(200 + t\) in the denominator. We'll have to solve this one using an integrating factor. To do so, start by writing it in standard FOLDE form: \[y' + \dfrac{2}{200+t}y = 2.\] \[P(t) = \dfrac{2}{200+t} \longrightarrow I(t) = e^{2\ln|200+t|} = e^{\ln |200+t|^2} = (200+t)^2\]

Now multiply this integrating factor through:

\[\begin{align} \left((200+t)^2y\right) &= 2(200+t)^2\\ (200+t)^2y &= \int 2(200+t)^2 \ dx\\ (200+t)^2y &= \dfrac{2}{3}(200+t)^3 + C\\ \\ y&= \dfrac{2}{3}(200+t)+\dfrac{C}{(200+t)^2} \end{align}\]

To find this constant, use the initial condition: if the tank is initially full of pure water, then \(y(0)=0\).

\[\begin{align} 0 &= \dfrac{2}{3}(200+2(0)) + \dfrac{C}{200^2}\\ 0 &= \dfrac{400}{3} + \dfrac{C}{40000}\\ -\dfrac{400}{3} &= \dfrac{C}{40000}\\ -\dfrac{16,000,000}{3} &= C\\ \end{align}\] \[\ans{y = \dfrac{2}{3}(200+t) + \dfrac{16,000,000}{(200+t)^2}}\]