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 lecture we focus on the first order linear equation. A first order equation is linear if we can put it into the form:

\[\label{eq:1}y' + p(x)y = f(x). \]

Here the word “linear” means linear in \(y\) and \(y'\); 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 \(\eqref{eq:1}\) as a derivative of a product of \(y\) with another function. To this end we find a function \(r(x)\) such that

This is the left hand side of \(\eqref{eq:1}\) multiplied by \(r(x)\). So if we multiply \(\eqref{eq:1}\) by \(r(x)\), we obtain

\[\frac{d}{dx}\left[r(x)y\right] = r(x)f(x)\]

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\). 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)\), such that if we differentiate it, we get the same function back multiplied by \(p(x)\). That seems like a job for the exponential function! Let

Of course, to get a closed form formula for \(y\), we need to be able to find a closed form formula for the integrals appearing above.

Example \(\PageIndex{1}\)

Solve

\[y' + 2xy = e^{x-x^2}, \quad y(0) = -1\]

Solution

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

We integrate \[\begin{align} \begin{aligned} e^{x^2} y &= e^x +C , \\ y &= e^{x-x^2} + C e^{-x^2} .\end{aligned}\end{align} \] Next, we solve for the initial condition \(-1 = y(0) = 1 + C\), so \(C=-2\). The solution is \[y = e^{x-x^2} - 2 e^{-x^2} .\]

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

Exercise \(\PageIndex{1}\)

Try it! Add a constant of integration to the integral in the integrating factor andshow that the solution you get in the end is the same as what we got above. An 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\[y' + p(x)y = f(x), \quad y(x_0) = y_0\]. Look at the solution and write the integrals as definite integrals.\[ \label{eq:17}y(x) = e^{\int-_{x_0}^x p(s)ds} \left(\int_{x_0}^x e^{\int_{x_0}^t p(s)ds} f(t) dt + y_0 \right) \]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.

Exercise \(\PageIndex{2}\)

Check that \(y(x_0) = y_0\) in formula \(\eqref{eq:17}\).

Exercise \(\PageIndex{3}\)

Write the solution of the following problem as a definite integral, but try to simplify as faras you can. You will not be able to find the solution in closed form.

\[y' + y = e^{x^2-x}, \quad y(0) = 10\]

Note

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)\), \(y(x_0) = y_0\), there is always an explicit formula \(\eqref{eq:17}\) for the solution. Second, it follows from the formula \(\eqref{eq:17}\) that if \(p(x)\) and \(f(x)\) are continuous on some interval \((a,b)\), then the solution \(y(x)\) exists and is differentiable on \((a,b)\). Compare with the simple nonlinear example we have seen previously, \(y'=y^2\), and compare to Theorem 1.2.1.

Example \(\PageIndex{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?

Solution

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

\[ \Delta x \approx \text{(rate in x concentration in)}\Delta t - \text{(rate out x concentration out)}\Delta t.\]

Dividing through by \(\Delta t\) and taking the limit \(\Delta t \rightarrow 0\) we see that

\[\frac{dx}{dt} = \text{(rate in x concentration in)} - \text{(rate out x concentration out)}\]