One of the most important types of equations we will learn how to solve are the so-called linear equations. In fact, the majority of the course is about linear equations. In this section we focus on the first order linear equation. A first order equation is linear if we can put it into the form:

\begin{equation}
y' + p(x) y = f(x) .\tag{1.3}
\end{equation}

The word “linear” means linear in \(y\) and \(y'\text{;}\) no higher powers nor functions of \(y\) or \(y'\) appear. The dependence on \(x\) can be more complicated.

Solutions of linear equations have nice properties. For example, the solution exists wherever \(p(x)\) and \(f(x)\) are defined, and has the same regularity (read: it is just as nice). But most importantly for us right now, there is a method for solving linear first order equations.

The trick is to rewrite the left-hand side of (1.3) as a derivative of a product of \(y\) with another function. To this end we find a function \(r(x)\) such that

\begin{equation*}
r(x) y' + r(x) p(x) y = \frac{d}{dx}\Bigl[ r(x) y \Bigr] .
\end{equation*}

This is the left-hand side of (1.3) multiplied by \(r(x)\text{.}\) So if we multiply (1.3) by \(r(x)\text{,}\) we obtain

\begin{equation*}
\frac{d}{dx}\Bigl[ r(x) y \Bigr] = r(x)f(x) .
\end{equation*}

Now we integrate both sides. The right-hand side does not depend on \(y\) and the left-hand side is written as a derivative of a function. Afterwards, we solve for \(y\text{.}\) The function \(r(x)\) is called the integrating factor and the method is called the integrating factor method.

We are looking for a function \(r(x)\text{,}\) such that if we differentiate it, we get the same function back multiplied by \(p(x)\text{.}\) That seems like a job for the exponential function! Let

First note that \(p(x) = 2x\) and \(f(x) = e^{x-x^2}\text{.}\) The integrating factor is \(r(x) = e^{\int p(x)\, dx} = e^{x^2}\text{.}\) We multiply both sides of the equation by \(r(x)\) to get

\begin{equation*}
\begin{aligned}
e^{x^2} y &= e^x +C , \\
y &= e^{x-x^2} + C e^{-x^2} .
\end{aligned}
\end{equation*}

Next, we solve for the initial condition \(-1 = y(0) = 1 + C\text{,}\) so \(C=-2\text{.}\) The solution is

\begin{equation*}
y = e^{x-x^2} - 2 e^{-x^2} .
\end{equation*}

Note that we do not care which antiderivative we take when computing \(e^{\int p(x) dx}\text{.}\) You can always add a constant of integration, but those constants will not matter in the end.

Advice: Do not try to remember the formula itself, that is way too hard. It is easier to remember the process and repeat it.

Since we cannot always evaluate the integrals in closed form, it is useful to know how to write the solution in definite integral form. A definite integral is something that you can plug into a computer or a calculator. Suppose we are given

You should be careful to properly use dummy variables here. If you now plug such a formula into a computer or a calculator, it will be happy to give you numerical answers.

Remark1.4.1.

Before we move on, we should note some interesting properties of linear equations. First, for the linear initial value problem \(y' + p(x) y = f(x)\text{,}\)\(y(x_0) = y_0\text{,}\) there is always an explicit formula (1.4) for the solution. Second, it follows from the formula (1.4) that if \(p(x)\) and \(f(x)\) are continuous on some interval \((a,b)\text{,}\) then the solution \(y(x)\) exists and is differentiable on \((a,b)\text{.}\) Compare with the simple nonlinear example we have seen previously, \(y'=y^2\text{,}\) and compare to Theorem 1.2.1.

Example1.4.2.

Let us discuss a common simple application of linear equations. This type of problem is used often in real life. For example, linear equations are used in figuring out the concentration of chemicals in bodies of water (rivers and lakes).

A 100 liter tank contains 10 kilograms of salt dissolved in 60 liters of water. Solution of water and salt (brine) with concentration of 0.1 kilograms per liter is flowing in at the rate of 5 liters a minute. The solution in the tank is well stirred and flows out at a rate of 3 liters a minute. How much salt is in the tank when the tank is full?

Let us come up with the equation. Let \(x\) denote the kilograms of salt in the tank, let \(t\) denote the time in minutes. For a small change \(\Delta t\) in time, the change in \(x\) (denoted \(\Delta x\)) is approximately

\begin{equation*}
\Delta x \approx
(\text{rate in} \times \text{concentration in}) \Delta t -
(\text{rate out} \times \text{concentration out}) \Delta t .
\end{equation*}

Dividing through by \(\Delta t\) and taking the limit \(\Delta t \to 0\text{,}\) we see that

We know \(5\) liters per minute are flowing in and \(3\) liters per minute are flowing out, so the volume is increasing by \(2\) liters a minute. So the tank is full when \(60+2t = 100\text{,}\) or when \(t=20\text{.}\) We are interested in the value of \(x\) when the tank is full, that is we want to compute \(x(20)\text{:}\)

See Figure 1.10 for the graph of \(x\) over \(t\text{.}\)

The concentration when the tank is full is approximately \(\nicefrac{11.86}{100} = \unitfrac[0.1186]{kg}{liter}\text{,}\) and we started with \(\nicefrac{1}{6}\) or 0.167 \(\nicefrac{\text{kg}}{\text{liter}}\text{.}\)

Subsection1.4.1Exercises

In the exercises, feel free to leave answer as a definite integral if a closed form solution cannot be found. If you can find a closed form solution, you should give that.

Solve \(\frac{1}{x^2+1} \, y' + x y = 3\text{,}\) with \(y(0) = 0\text{.}\)

Exercise1.4.9.

Suppose there are two lakes located on a stream. Clean water flows into the first lake, then the water from the first lake flows into the second lake, and then water from the second lake flows further downstream. The in and out flow from each lake is 500 liters per hour. The first lake contains 100 thousand liters of water and the second lake contains 200 thousand liters of water. A truck with 500 kg of toxic substance crashes into the first lake. Assume that the water is being continually mixed perfectly by the stream.

Find the concentration of toxic substance as a function of time in both lakes.

When will the concentration in the first lake be below 0.001 kg per liter?

When will the concentration in the second lake be maximal?

Exercise1.4.10.

Newton’s law of cooling states that \(\frac{dx}{dt} = -k(x-A)\) where \(x\) is the temperature, \(t\) is time, \(A\) is the ambient temperature, and \(k > 0\) is a constant. Suppose that \(A = A_0 \cos (\omega t)\) for some constants \(A_0\) and \(\omega\text{.}\) That is, the ambient temperature oscillates (for example night and day temperatures).

Find the general solution.

In the long term, will the initial conditions make much of a difference? Why or why not?

Exercise1.4.11.

Initially 5 grams of salt are dissolved in 20 liters of water. Brine with concentration of salt 2 grams of salt per liter is added at a rate of 3 liters a minute. The tank is mixed well and is drained at 3 liters a minute. How long does the process have to continue until there are 20 grams of salt in the tank?

Exercise1.4.12.

Initially a tank contains 10 liters of pure water. Brine of unknown (but constant) concentration of salt is flowing in at 1 liter per minute. The water is mixed well and drained at 1 liter per minute. In 20 minutes there are 15 grams of salt in the tank. What is the concentration of salt in the incoming brine?

Suppose a water tank is being pumped out at 3 \(\nicefrac{\text{L}}{\text{min}}\text{.}\) The water tank starts at 10 L of clean water. Water with toxic substance is flowing into the tank at 2 \(\nicefrac{\text{L}}{\text{min}}\text{,}\) with concentration \(20t\)\(\nicefrac{\text{g}}{\text{L}}\) at time \(t\text{.}\) When the tank is half empty, how many grams of toxic substance are in the tank (assuming perfect mixing)?

There is bacteria on a plate and a toxic substance is being added that slows down the rate of growth of the bacteria. That is, suppose that \(\frac{dP}{dt} = (2-0.1\,t)P\text{.}\) If \(P(0) = 1000\text{,}\) find the population at \(t=5\text{.}\)

A cylindrical water tank has water flowing in at \(I\) cubic meters per second. Let \(A\) be the area of the cross section of the tank in square meters. Suppose water is flowing out from the bottom of the tank at a rate proportional to the height of the water level. Set up the differential equation for \(h\text{,}\) the height of the water, introducing and naming constants that you need. You should also give the units for your constants.