Holt.Blue
Back To Class Notes Menu
First-Order Linear Differential Equations

Today we begin to solve differential equations which may not separable.

In particular, we will solve first-order linear equations.

































First-Order Linear Differential Equations

A first-order differential equation is linear if it can be written in the form $$a(x)y' + b(x)y = c(x),$$ where $a(x),$ $b(x),$ and $c(x)$ are arbitrary functions of $x.$































First-Order Linear Differential Equations: Standard Form

In order to solve $a(x)y' + b(x)y = c(x),$ we will first divide both sides by $a(x)$ into the form $$\displaystyle y' + \frac{b(x)}{a(x)}y = \frac{c(x)}{a(x)},$$ which we will simply write as $$y'+p(x)y=q(x).$$ This last form is called standard form.































Solving $y' + p(x)y = q(x)$: Integrating Factors

To solve the above equation we will multiply both sides by a function $\mu(x)$ which will do something special...

$\mu(x)$ is called an integrating factor.

First we multiply through by a function $\mu(x)$ $$ \mu(x)y' + \mu(x)p(x)y = \mu(x)q(x) $$ with the hope of getting $$ (\mu(x)y)'=\mu(x)q(x). $$ Then, for the above two equations to be equivalent, we set the left hand sides equal to one another. $$ \mu(x)y' + \mu(x)p(x)y=(\mu(x)y)' $$ By the Product Rule, it follows that $$ \mu(x)y' + \mu(x)p(x)y=\mu'(x)y+\mu(x)y' $$ Cancelling the outer terms, $$ \mu(x)p(x)y=\mu'(x)y $$ Dividing out $y,$ $$ \mu(x)p(x)=\mu'(x) $$ Rewriting the above in differential form, $$ \frac{d\mu}{dx}=p(x)\mu $$ we see that we may separate variables and solve $$ \begin{array}{lll} &\displaystyle \frac{d\mu}{\mu}&=p(x)\,dx\\ \implies &\displaystyle \int \frac{d\mu}{\mu}&=\displaystyle \int p(x)\,dx +C\\ \implies &\displaystyle \ln|\mu|&=\displaystyle \int p(x)\,dx+C\\ \implies &\displaystyle |\mu|&=\displaystyle e^{\int p(x)\,dx+C}\\ \implies &\displaystyle |\mu|&=\displaystyle e^{\int p(x)\,dx} e^{C}\\ \implies &\displaystyle \mu&=\displaystyle \pm e^{C} e^{\int p(x)\,dx} \\ \implies &\displaystyle \mu&=\displaystyle Ce^{\int p(x)\,dx} \\ \end{array} $$ Since any $C$ will work, simply choose $C=1$ so that $$ \mu=e^{\int p(x)\,dx} $$


































Solving $y' + p(x)y = q(x)$: Integrating Factors

Thus, our integrating factor that turns the left-hand side into the derivative of a product is $$\mu(x)=e^{\int p(x) \, dx}$$

































Example

Solve the first-order linear equation. Assume $x \gt 0.$

$xy'=3y+x^2$

Rewriting the equation in standard form, $$ y'-\frac{3}{x}y=x, $$ our integrating factor is $$e^{\int -\frac{3}{x} \,dx}=e^{-3\ln x}=e^{\ln x^{-3}}=x^{-3}=\frac{1}{x^3}.$$

Continuing on, we multiply through by the integrating factor. $$ \frac{1}{x^3}y'-\frac{3}{x^4}y=\frac{1}{x^2} $$ Then, by the Product Rule, $$ \left(\frac{1}{x^3}y\right)'=\frac{1}{x^2} $$ We then have $$ \begin{array}{ll} & \displaystyle \frac{1}{x^3}y=\int \frac{1}{x^2} \,dx\\ \implies & \displaystyle \frac{1}{x^3}y=-\frac{1}{x}+C\\ \implies & \displaystyle y=-x^2+Cx^3\\ \end{array} $$ Checking our work with the original equation, $$ \begin{array}{l|l} \mbox{Left Hand Side} & \mbox{Right Hand Side}\\ xy' & 3y+x^2\\ =x(-x^2+Cx^3)' & =3(-x^2+Cx^3)+x^2\\ =x(-2x+3Cx^2) & =-3x^2+3Cx^3+x^2\\ =-2x^2+3Cx^3 \checkmark & =-2x^2+3Cx^3 \checkmark\\ \end{array} $$




































Process

1. Put the equation into standard form and identify $p(x)$ and $q(x).$

2. Calculate the integrating factor $\mu(x)=e^{\int p(x) \, dx}$.

3. Multiply both sides of the differential equation by $\mu(x).$

4. Write the left-hand side as a derivative of a product of $\mu(x)$ and $y$ ("reverse" product rule).

5. Integrate both sides of the equation obtained in step 4, and divide both sides by $\mu(x).$

6. If there is an initial condition, determine the value of $C.$

































Example

Solve the initial value problem.

$(1+x^2)y'=y-1,$ $y(0) = 0$

We first find the general solution. Getting the equation into standard form, $$ \begin{array}{lrll} &\displaystyle (1+x^2)y' &=\displaystyle y-1&\mbox{}\\ \implies &\displaystyle y' &=\displaystyle \frac{1}{x^2+1}y-\frac{1}{x^2+1} &\mbox{}\\ \implies &\displaystyle y' -\frac{1}{x^2+1}y&=\displaystyle -\frac{1}{x^2+1} &\mbox{}\\ \end{array} $$ Our integrating factor is then $$ e^{\int -\frac{1}{x^2+1}\,dx}=e^{-\tan^{-1} x} $$ Thus, $$ \begin{array}{lrll} &\displaystyle e^{-\tan^{-1} x} y' -e^{-\tan^{-1} x}\frac{1}{x^2+1} y&=\displaystyle -e^{-\tan^{-1} x}\frac{1}{x^2+1} &\mbox{}\\ \implies &\displaystyle \left(e^{-\tan^{-1} x} y\right)'&=\displaystyle -e^{-\tan^{-1} x}\frac{1}{x^2+1} &\mbox{ using the Product Rule}\\ \implies &\displaystyle e^{-\tan^{-1} x} y&=\displaystyle \int -e^{-\tan^{-1} x}\frac{1}{x^2+1} \,dx&\mbox{}\\ \implies &\displaystyle e^{-\tan^{-1} x} y&=\displaystyle e^{-\tan^{-1} x}+C&\mbox{using the substitution $u=-\tan^{-1} x$}\\ \implies &\displaystyle y&=\displaystyle 1+Ce^{\tan^{-1}x}&\mbox{multiplying both sides by $e^{\tan^{-1} x}$}\\ \end{array} $$ Checking our general solution with the original equation, $$ \begin{array}{l|l} \mbox{Left Hand Side} & \mbox{Right Hand Side}\\ (1+x^2)y' & y-1\\ =\displaystyle (1+x^2)\left(1+Ce^{\tan^{-1}x}\right)'& =\displaystyle 1+Ce^{\tan^{-1}x}-1\\ =\displaystyle (1+x^2)\left(Ce^{\tan^{-1}x}\frac{1}{x^2+1}\right)& =\displaystyle 1+Ce^{\tan^{-1}x}-1\\ =\displaystyle Ce^{\tan^{-1}x} \checkmark & =\displaystyle Ce^{\tan^{-1}x}\checkmark\\ \end{array} $$ We now satisfy the initial condition, $y(0)=0.$ $$ \begin{array}{llll} &\displaystyle y(0)&=0\displaystyle &\mbox{}\\ \implies &\displaystyle 1+Ce^{\tan^{-1}0} &=\displaystyle 0&\mbox{}\\ \implies &\displaystyle 1+C &=\displaystyle 0&\mbox{}\\ \implies &\displaystyle C &=\displaystyle -1&\mbox{}\\ \end{array} $$ Thus, $y=1-e^{\tan^{-1}x}$ is a particular solution which satisfies the initial condition.




































Application: Another Mixture Problem

A tank contains $50 \mbox{ kg}$ of salt dissolved in $5000 \mbox{ L}$ of water. A salt solution of $0.02 \mbox{ kg}$ salt per liter is pumped into the tank at a rate of $125$ liters per minute and is drained at a rate of $250$ liters per minute. Solve for the amount of salt at time $t.$ Assume the tank is always being stirred and is well mixed.



The key difference between this mixture problem and the one we encountered earlier is that the rate the solution flowing into the tank is not the same as the rate flowing out.

Let $A(t)$ be the amount of salt in the tank at time $t.$

The overall rate at which the salt is changing can be determined by the rate at which salt is entering the tank and the rate at which it is leaving the tank. That is, $$ \frac{dA}{dt}=\mbox{Rate Salt Enters Tank}-\mbox{Rate Salt Leaves Tank}. $$ Rate Salt Enters Tank: The solution enters the tank at a rate of $125 \frac{\mbox{L}}{\mbox{min}},$ and since the concentration is $0.02 \frac{\mbox{kg}}{\mbox{L}},$ the rate at which the salt is entering the tank is $$ \mbox{Rate Salt Enters Tank}=\color{magenta}{\mbox{Rate Volume In}}\cdot\color{blue}{\mbox{Concentration}}=\color{magenta}{125 \frac{\mbox{L}}{\mbox{min}}} \cdot \color{blue}{0.02 \frac{\mbox{kg}}{\mbox{L}}}=2.5 \frac{\mbox{kg}}{\mbox{min}} $$ Rate Salt Leaves Tank: The solution is draining at a rate of $250 \frac{\mbox{L}}{\mbox{min}}.$ Since $125 \mbox{ L}$ are entering the tank per minute while $250 \mbox{ L}$ are draining, the volume of liquid is decreasing by $125 \mbox{ L}$ per minute. Thus, the volume of mixture in the tank at time $t$ is given by the expression $5000-125t.$

Also, the total amount salt in the tank $A(t)$ is changing at every moment $t,$ the concentration of salt in the tank also depends on time.

The concentration at time $t$ is $\displaystyle \frac{A(t) \mbox{ kg}}{5000-125t \mbox{ L}}.$ We then have $$ \begin{array}{ll} \mbox{Rate Salt Leaves Tank}&=\color{magenta}{\mbox{Rate Volume Out}}\cdot\color{blue}{\mbox{Concentration}}\\ &=\displaystyle \color{magenta}{250 \frac{\mbox{L}}{\mbox{min}}} \cdot \color{blue}{\frac{A(t) \mbox{ kg}}{5000-125t \mbox{ L}}}\\ &=\displaystyle \frac{250}{5000-125t}A(t)\frac{\mbox{kg}}{\mbox{min}}\\ &=\displaystyle \frac{2}{40-t}A(t)\frac{\mbox{kg}}{\mbox{min}}\\ \end{array} $$ Thus, the differential equation which $A(t)$ satisfies is $$ \frac{dA}{dt}=2.5-\frac{2}{40-t}A $$ In standard form we have $$ \frac{dA}{dt}+\frac{2}{40-t}A=2.5 $$ This is a linear, first-order equation. We begin by finding the general solution which requires computing the integrating factor. $$ \begin{array}{lll} \displaystyle e^{\int p(t) \, dt}&\displaystyle=e^{\int \frac{2}{40-t} \, dt} &\mbox{}\\ \displaystyle &\displaystyle= e^{-2\ln(40-t)}&\mbox{}\\ \displaystyle &\displaystyle= e^{\ln\left(\left(40-t\right)^{-2}\right)}&\mbox{}\\ \displaystyle &\displaystyle= (40-t)^{-2}&\mbox{}\\ \end{array} $$ Then $$ \begin{array}{ll} &\displaystyle \frac{dA}{dt}+\frac{2}{40-t}A=2.5\\ \implies &\displaystyle (40-t)^{-2}\frac{dA}{dt}+(40-t)^{-2}\frac{2}{40-t}A=2.5(40-t)^{-2}\\ \implies &\displaystyle (40-t)^{-2}\frac{dA}{dt}+2(40-t)^{-3}A=2.5(40-t)^{-2}\\ \implies &\displaystyle \left((40-t)^{-2}A\right)'=2.5(40-t)^{-2}\\ \implies &\displaystyle (40-t)^{-2}A=2.5\int (40-t)^{-2}\,dt\\ \implies &\displaystyle (40-t)^{-2}A=2.5\cdot (40-t)^{-1}+C\\ \implies &\displaystyle A=2.5(40-t)^{-1}(40-t)^{2}+C(40-t)^{2}\\ \implies &\displaystyle A=2.5(40-t)+C(40-t)^{2}\\ \end{array} $$ Since there are $50 \mbox{ kg}$ of salt to start with in the tank, our initial condition is $A(0)=50.$ Thus, $$ \begin{array}{ll} &A(0)=50\\ \implies &\displaystyle 2.5(40-0)+C(40-0)^{2}=50\\ \implies &\displaystyle 2.5(40)+C(40)^{2}=50\\ \implies &\displaystyle C(40)^{2}=50-2.5(40)\\ \implies &\displaystyle C=\frac{50-2.5(40)}{40^{2}}\\ \implies &\displaystyle C=-\frac{1}{32}\\ \end{array} $$ The particular solution is then $$ A(t)=2.5(40-t)-\frac{1}{32}(40-t)^{2} $$ A graph of this solution is given below.

































Example

Find the general solution to the equation $y'-2xy=1$ and then satisfy the initial condition $y(0)=1.$

Our integrating factor is $e^{\int (-2x)\,dx}=e^{-x^2}.$

Then $$ \begin{array}{lll} &\displaystyle y'-2xy =1 &\mbox{}\\ \implies &\displaystyle e^{-x^2}y'-2xe^{-x^2}y =e^{-x^2}&\mbox{}\\ \implies &\displaystyle \left(e^{-x^2}y\right)' =e^{-x^2}&\mbox{}\\ \implies &\displaystyle e^{-x^2}y =\int_{x_0}^{x} e^{-t^2} \,dt +C&\mbox{}\\ \implies &\displaystyle y =e^{x^2}\int_{x_0}^{x} e^{-t^2} \,dt+Ce^{x^2}&\mbox{}\\ \end{array} $$ where $x_0$ is an initial value.

We notice that $e^{-x^2}$ has no elementary antiderivative, so we express the antiderivative as a definite integral $\displaystyle \int_{x_0}^{x} e^{-t^2} \,dt$ since the FTC says that $\displaystyle \frac{d}{dx}\int_{x_0}^{x} e^{-t^2} \,dt=e^{-x^2}.$

Since there are really nice techniques for approximating such integrals, in practice this isn't really a big deal.

We now satisfy the initial condition. Since $y(0)=1,$ we take $x_0=0.$

Then $$ \begin{array}{lll} &\displaystyle y(0)=1&\mbox{}\\ \implies &\displaystyle e^{0^2}\int_{0}^{0} e^{-t^2} \,dt+Ce^{0^2}=1&\mbox{}\\ \implies &\displaystyle 1\cdot 0 +C\cdot 1=1&\mbox{}\\ \implies &\displaystyle C =1&\mbox{}\\ \end{array} $$ Our particular solution is then $$y =e^{x^2}\int_{0}^{x} e^{-t^2} \,dt+e^{x^2}=e^{x^2}\left(\int_{0}^{x} e^{-t^2} \,dt+1\right)$$