Artificial Intelligence 🤖
Differential equations
Ordinary differential equations
Linear ODEs

Linear ODEs

The separable ODEs we have encountered in Section 12.1, can be linear or nonlinear. The method of separating variables can be applied to an ODE whose form matches the one given by Eq. (12.2). In this section, we focus on a method that applies to linear ordinary differential equations. We start off by defining the most general first order, linear ODE expressed in standard form as follows

dydx+p(x)y=f(x)\frac{d y}{d x}+p(x) y=f(x)

where y=y(x)y=y(x). Note that standard form implies that the coefficient of the derivative, dy/dxd y / d x is 1 . This is especially important when using the formula given later in Subsec. 12.2.1 to obtain the solution to the ODE.

A first order ODE is linear if:

  1. the function y(x)y(x) and its derivative y(x)y^{\prime}(x) are not present at any power higher than 1 ;
  2. there are no products of the function y(x)y(x) and its derivative, y(x)y^{\prime}(x).

We note that the functions p(x)p(x) and f(x)f(x) in Eq. (12.19) should be continuous but they may be represented by constant, noncontant, linear, or nonlinear functions. A reminder of the definition of continuity is given in the next Definition.

Definition 12.2 A function f(x)f(x) is continuous at a point x=ax=a if:

  1. f(a)f(a) is defined;
  2. limxaf(x)\lim _{x \rightarrow a} f(x) exists;
  3. limxaf(x)=f(a)\lim _{x \rightarrow a} f(x)=f(a).

In the case where the function on the RHS of Eq. (12.19) is zero, then the ODE (12.19) is separable: setting f(x)=0f(x)=0 in Eq. (12.19), yields,

dydx+p(x)y=0\frac{d y}{d x}+p(x) y=0

Equation (12.20) is now a separable ODE and can easily be solved using the technique outlined in Sec. 12.1.

General solution

For first order, linear ODEs the solution to the differential equation may be expressed by the following general formula,

y(x)=μ(x)f(x)dxμ(x).y(x)=\frac{\int \mu(x) f(x) d x}{\mu(x)} .

In Eq. (12.21), f(x)f(x) is the RHS of Eq. (12.19) (again, note that this is true when the ODE is expressed in standard form). The function μ(x)\mu(x) is referred to as the integrating factor (I.F.). Integrating factors are often introduced in equations involving differentials to help us follow a solution technique. Here, we use an I.F. that is guaranteed to work for first order, linear ODEs. Later in this chapter, we discuss another I.F. which is to be used to turn inexact to exact ODEs (see Subsec. 12.4.3).

Derivation of solution formula

While having formulae available to express solutions to certain types of ODEs is useful in application, memorising them offers little insight into the mathematics of differential equations. Here, we derive the general solution formula given by Eq. (12.21) starting from the linear ordinary differential equation (LODE), given by Eq. (12.19). 1. Assume there exists an I.F. given by μ(x)\mu(x) where μ(x)0\mu(x) \neq 0. Starting from the standard form ODE (12.19), multiply by said factor.

μ(x)dydx+μ(x)p(x)y=μ(x)f(x)\mu(x) \frac{d y}{d x}+\mu(x) p(x) y=\mu(x) f(x)
  1. Our objective is to find an I.F. that allows us to express the entire LHS of Eq. (12.22) as the derivative of something. We observe that we can reduce the LHS of (12.22) as follows
 LHS of Eq. (12.22)=ddx[μ(x)y(x)]\text { LHS of Eq. }(12.22)=\frac{d}{d x}[\mu(x) y(x)]

as long as the following ODE is satisfied,

dμdx=μ(x)p(x)\frac{d \mu}{d x}=\mu(x) p(x)

Note that μ(x)\mu(x) is a function which we define ourselves to facilitate the solution of the ODE; for this reason, we are free to define the ODE in Eq. (12.24). Equation (12.24) represents an ODE which we can solve for the I.F., μ(x)\mu(x).

  1. Reducing the LHS of Eq. (12.22) to the form given by (12.23), we can express the ODE (12.22) as
ddx[μ(x)y(x)]=μ(x)f(x)\frac{d}{d x}[\mu(x) y(x)]=\mu(x) f(x)

where y(x)y(x) is what we want to solve for.

  1. To solve for y(x)y(x), we integrate both sides of Eq. (12.25) wrt xx. Note that, as the xx-derivative of a product, integrating wrt xx simply gives the product itself:
μ(x)y(x)=μ(x)f(x)dx.\mu(x) y(x)=\int \mu(x) f(x) d x .
  1. Finally, solving for y(x)y(x) gives the formula given previously in Eq. (12.21).

Integrating factor

The derivation of the solution given by Eq. (12.21) is subject to the condition given by Eq. (12.24). The condition (12.24) is an ODE for μ(x)\mu(x) ( xx is the independent variable, μ\mu is the dependent variable) and it is separable. Therefore, by separating the variables in Eq. (12.24),

1μdμ=p(x)dx.\frac{1}{\mu} d \mu=p(x) d x .

Integrating both sides of Eq. (12.27),

lnμ=p(x)dx\ln \mu=\int p(x) d x

Exponentiating both sides of Eq. (12.28) yields μ(x)\mu(x), as

μ(x)=ep(x)dx.\mu(x)=e^{\int p(x) d x} .

Equation (12.29) represents the integrating factor for a first order, LODE, in standard form. A typical solution process for first order, LODEs is given next.

General solution method

Here we outline a solution technique to solve LODEs of the form given by (12.19), or any LODE that can be put in that form. Note again that this is used for f(x)0f(x) \neq 0; for f(x)=0f(x)=0, we use the method of separation of variables.

Step 1: Check if the ODE is in standard form; if not, put ODE in standard form.

Step 2: Find the integrating factor using

μ(x)=ep(x)dx.\mu(x)=e^{\int p(x) d x} .

First, integrate p(x)p(x) wrt xx (or, more accurately, find any function whose derivative is p(x)p(x); in other words, when integrating p(x)p(x) wrt xx, ignore constants of integration). Second, exponentiate the integration result to obtain μ(x)\mu(x).

Step 3: Multiply the ODE throughout by the I.F. [like in Eq. (12.22).

Step 4: The LHS of the ODE obtained in Step 3 is always equivalent to

ddx[μ(x)y(x)]\frac{d}{d x}[\mu(x) y(x)]

Checking that this is true verifies that the I.F. has been found correctly. Rewrite the ODE so that the LHS is written in the reduced form [like in Eq. (12.25)].

Step 5: Integrate both sides wrt xx to obtain the solution [like in Eq. (12.26)]. Note, that if you were to include a constant of integration in Step 2, this would ultimately be grouped with the constant of integration obtained in this step. For a first order ODE, the general solution can at most have one unknown constant to be solved with a single IC.

The idea behind the solution technique outlined in this section is that, given the appropriate integrating factor, it possible to express the LHS of Eq. (12.19) as the xx-derivative of a product of functions; this technique makes it exceptionally easy to solve linear ODEs which at first sight may look tedious and complicated. Now let us look at a specific example to demonstrate the ideas communicated in the solution process in this section. Example 12.3 Find the general solution to the following ODE,

dydxyx=x2\frac{d y}{d x}-\frac{y}{x}=x^{2}

Solution We note that the ODE is a first order, LODE so we can use the integrating factor method to arrive at a solution for y(x)y(x).

  1. The ODE is already in standard form with p(x)=1/xp(x)=-1 / x and f(x)=x2f(x)=x^{2}.
  2. Obtain the I.F. using Eq. (12.29).

(a) Find the integral of p(x)p(x) :

p(x)dx=1xdx=lnx1\begin{aligned} \int p(x) d x & =-\int \frac{1}{x} d x \\ & =\ln x^{-1} \end{aligned}

(b) Exponentiate the result to find μ(x)\mu(x) :

μ(x)=elnx1=1x\begin{aligned} \mu(x) & =e^{\ln x^{-1}} \\ & =\frac{1}{x} \end{aligned}
  1. Multiply ODE(12.30)\operatorname{ODE}(12.30) by μ(x)=1/x\mu(x)=1 / x :
1xdydxyx2=x\frac{1}{x} \frac{d y}{d x}-\frac{y}{x^{2}}=x
  1. The LHS of Eq. (12.31) is equivalent to ddx[y(x)x]\frac{d}{d x}\left[\frac{y(x)}{x}\right].
 Check: ddx[y(x)x]=1xdydx+y(1x2)\text { Check: } \quad \frac{d}{d x}\left[\frac{y(x)}{x}\right]=\frac{1}{x} \frac{d y}{d x}+y\left(\frac{-1}{x^{2}}\right)

Rewriting (12.31) using the reduced form of the LHS,

ddx[y(x)x]=x\frac{d}{d x}\left[\frac{y(x)}{x}\right]=x

Integrating both sides of Eq. (12.32) wrt xx

1xy(x)=xdx\frac{1}{x} y(x)=\int x d x

which gives the general solution as

y(x)=x32+cxy(x)=\frac{x^{3}}{2}+c x

Mixing problems

In this course we will deal with so-called mixing problems which typically involve a 'tank' into which a certain substance is added at a certain input rate (measured in units of [ mass ][ time ]\frac{[\text { mass }]}{[\text { time }]} ) and the substance leaves the system at a certain output rate (also measured in units of [ mass ][ time ])\left.\frac{[\text { mass }]}{[\text { time }]}\right). Figure 12.2 shows a schematic of a typical setup; the inlet stream may contain a mixture of solute and solvent or pure solvent while the exit stream contains the well-mixed solute and solvent. At any time, tt, there exists some amount of solute in the mixing tank which we denote by y(t)y(t). Our objective is to formulate an ODE to solve for the amount of solute in the tank at tt; we can describe this mathematically by considering a material balance as follows:

dydt= rate in  rate out. \frac{d y}{d t}=\text { rate in }- \text { rate out. }

Figure 12.2: A typical setup of a mixing tank showing inlet and outlet streams.

These types of problems are often described by first order, linear ODEs which may be solved by the technique outlined in this section. The rates are described by the product of a flowrate ([volume]/[time]) and concentration ([mass]/[volume]). Typical notation for flowrate in, out is given by Fin ,Fout F_{\text {in }}, F_{\text {out }} and inlet concentration is denoted by cin c_{\text {in }}. The outlet concentration is unknown, time-dependent, and it is the quantity we associate with yy, the amount of solute in the tank:

cout =y(t)V(t).c_{\text {out }}=\frac{y(t)}{V(t)} .

Note that while Fin ,Fout ,cin F_{\text {in }}, F_{\text {out }}, c_{\text {in }} are usually known parameters and constant in such problems, they may also be functions of time and/or space. Expressing ODE (12.34) in terms of the new notation, we have

dydt=Fin cin Fout y(t)V(t)\frac{d y}{d t}=F_{\text {in }} c_{\text {in }}-F_{\text {out }} \frac{y(t)}{V(t)}

where V(t)V(t) is the volume of liquid in the tank. Equation (12.35) is a linear, first order ODE for y(t)y(t). In order to arrive at an ordinary different equation describing the problem (i.e. a single independent variable in the DE), we assume that mixing is done instantaneously. This implies that once the inlet stream contents enter the tank, mixing is done instantaneously such that the concentration is not space dependent and yy only varies with time. In Eq. (12.35), the volume of liquid in the tank, V(t)V(t), may: be constant if Fin =Fout F_{\text {in }}=F_{\text {out }} such that the level of the liquid remains unchanged, increase if Fin >Fout F_{\text {in }}>F_{\text {out }}, or decrease if Fin <Fout F_{\text {in }}<F_{\text {out }}.

Example 12.4 A tank initially holds 100 L100 \mathrm{~L} of solution containing 1 kg1 \mathrm{~kg} of dissolved salt. A solution of water and salt enters the tank at a rate of 3 L/min3 \mathrm{~L} / \mathrm{min} containing 0.05 kg/L\mathrm{kg} / \mathrm{L} of salt. The mixture flows out of the tank at a rate of 3 L/min3 \mathrm{~L} / \mathrm{min}. Formulate the IVP and determine the amount of salt in the tank at time tt.

Solution To formulate the IVP, we need to perform a material balance to describe the rate of change of amount of salt in tank and provide an IC giving the amount of salt initially i.e. at t=0t=0. Following (12.35),

dydt=3×0.053y100,y(0)=1.\frac{d y}{d t}=3 \times 0.05-3 \frac{y}{100}, \quad y(0)=1 .

Note that V=100V=100 is constant since Fin =Fout =3F_{\text {in }}=F_{\text {out }}=3. The ODE (12.36) is linear and can therefore be solved using an I.F. but it is also separable since it can be put in the form of (12.1). Here, we choose to use the I.F. method. When (12.36) is expressed in standard form, we have p(t)=3/100p(t)=3 / 100 and f(t)=0.15f(t)=0.15; the I.F. is:

μ(t)=ep(t)dt=e3t/100.\mu(t)=e^{\int p(t) d t}=e^{3 t / 100} .

With the help of the I.F., we can rewrite the standard form version of ODE (12.36) as

ddt[e3t/100y(t)]=0.15e3t/100\frac{d}{d t}\left[e^{3 t / 100} y(t)\right]=0.15 e^{3 t / 100}

which, upon integration, gives the general solution as:

y(t)=5+ce3t/100.y(t)=5+c e^{-3 t / 100} .

Finally, applying the IC y(0)=1y(0)=1, we obtain the following particular solution,

y(t)=54e3t/100.y(t)=5-4 e^{-3 t / 100} .

The limiting value of yy (i.e. as tt \rightarrow \infty ) is 5 kg5 \mathrm{~kg}, which corresponds to a concentration of 0.05 kg/L0.05 \mathrm{~kg} / \mathrm{L}. This value is equivalent to the concentration of the inlet stream. This makes sense since the inlet and outlet flowrates are equal, it is expected that, after a long time, the concentration of salt in the tank approaches that of the inlet stream.

Exercises

  1. Solve the following IVP,
xdydx+3y=sinxx2,x0,y(π/2)=1.x \frac{d y}{d x}+3 y=\frac{\sin x}{x^{2}}, \quad x \neq 0, y(\pi / 2)=1 .
  1. Solve the following ODE giving your answer in explicit form,
tanxdydx+y=1,sinx>0\tan x \frac{d y}{d x}+y=1, \quad \sin x>0
  1. A tank initially holds 200 L200 \mathrm{~L} of solution containing 5 kg5 \mathrm{~kg} of dissolved salt. A solution of water and salt enters the tank at a rate of 3 L/min3 \mathrm{~L} / \mathrm{min} containing 50 g/L50 \mathrm{~g} / \mathrm{L} of salt. The mixture flows out of the tank at a rate of 3 L/min3 \mathrm{~L} / \mathrm{min}. The maximum capacity of the tank is Vmax=500 LV_{\max }=500 \mathrm{~L}. Formulate the IVP and determine the concentration of the salt in the tank when the tank is at the point of overflowing.