Definition of First-order Linear ODEs
First-order Linear ODEs are first-order ODEs that can be written in the form of
\begin{equation}
\frac{dy}{dx} + P(x) y = Q(x) \tag{1}
\end{equation}
where \( P(x), Q(x) \) are some functions of the independent variable \( x \). \( Q(x) \) is often referred to as the non-homogeneous/source term. Examples are:
- \( dy/dx + (\cos x) y = e^{-x^2} \)
- \( dy/dx -3y = 0 \)
- \( dy/dx -x^2 e^{x} y = 1 -\sqrt{x} \)
Solution Method: Integrating Factor
To solve first-order linear ODEs, we set out to find an integrating factor \( \mu(x) \) such that multiplying it on both sides of (1) gives
\begin{equation}
\mu(x) \frac{dy}{dx} + \mu(x)P(x)y = \mu(x)Q(x) \tag{2}
\end{equation}
and we require that the two terms on the L.H.S. can be grouped as a single derivative:
\begin{equation}
\mu(x) \frac{dy}{dx} + \color{red}{\mu(x)P(x)y} = \frac{d}{dx}(\mu(x)y) \tag{3}
\end{equation}
but also, by Product Rule:
\begin{equation}
\frac{d}{dx}(\mu(x)y) = \mu(x) \frac{dy}{dx} + \color{red}{\frac{d\mu(x)}{dx}y} \tag{4}
\end{equation}
Comparing (3) and (4), for it to work, we need
\begin{equation}
\frac{d\mu(x)}{dx} = \mu(x)P(x) \tag{5}
\end{equation}
Recalling the last tutorial, we can use Separation of Variables to arrive at
\begin{align}
\int \frac{d\mu(x)}{\mu(x)} &= \int P(x) dx \\
\ln |\mu(x)| &= \int P(x) dx \\
\mu(x) &= \exp( \int P(x) dx ) \tag{6}
\end{align}
This will be the form of the integrating factor (here the integration constant and absolute sign do not matter), and applying (3) to (2) will lead to the desired solution:
\begin{align}
\frac{d}{dx}(\mu(x)y) &= \mu(x)Q(x) \\
\mu(x)y &= \int \mu(x)Q(x) dx \\
y &= \frac{1}{\mu(x)}\int \mu(x)Q(x) dx + C \tag{7}
\end{align}
where the integration constant is needed now.
Examples
Our first example is to solve
\begin{equation}
\frac{dy}{dx} + 4xy = e^{-2x^2} \tag{8}
\end{equation}
with the initial condition \( y(0) = -1 \). Here \( P(x) = 4x \), and by (6) the integrating factor is hence
\begin{equation}
\mu(x) = \exp( \int P(x) dx ) = \exp( \int 4x dx ) = e^{2x^2} \tag{9}
\end{equation}
By multiplying this on both sides of (8) and carrying out integration, we obtain
\begin{align}
e^{2x^2}\frac{dy}{dx} + 4xe^{2x^2}y &= 1 \\
\frac{d}{dx}(e^{2x^2}y) &= 1 \\
e^{2x^2}y &= \int dx = x + C\\
y &= \color{red}{xe^{-2x^2}} + \color{green}{Ce^{-2x^2}} \tag{10}
\end{align}
The red term is called the particular solution, produced by the non-homogeneous source term Q(x) and no integration constant is involved. Meanwhile, the green term is known as the complementary solution, induced by the homogeneous part, accompanied by an integration constant.
Plugging in the I.C., we have
\begin{align}
(-1) &= (0)e^{-2(0)^2} + Ce^{-2(0)^2} \\
-1 &= 0(1) + C(1) \Rightarrow C = -1 \tag{11}
\end{align}
So the general solution will be
\begin{equation}
y = xe^{-2x^2} – e^{-2x^2} = (x-1)e^{-2x^2} \tag{12}
\end{equation}
Falling Objects
Another example is the simple scenario of a downward-falling object subjected to gravity as well as linear air resistance. Denote the downward velocity at time \( t \) as \( v(t) \), the acceleration can be modelled to follow
\begin{equation}
\frac{dv}{dt} = g -\alpha v \tag{13}
\end{equation}
where \( \alpha \) is a constant representing the magnitude of air resistance and has a unit of \( \text{s}^{−1} \). The task is to express the velocity \( v(t) \) as well as the downward displacement \( s(t) = \int v(t)dt \) in terms of the time elapsed \( t \) since released from rest. Also, if the object reaches 90% of the terminal speed at \(t = 10 \text{ s}\), find the value of \( \alpha \).
To tackle the ODE, we move the \( \alpha v \) term from R.H.S. to L.H.S. to transform it into the linear form:
\begin{equation}
\frac{dv}{dt} + \alpha v = g \tag{14}
\end{equation}
From (6), the integrating factor is
\begin{equation}
\mu(t) = \exp( \int \alpha dt ) = \exp(\alpha t) \tag{15}
\end{equation}
Multiplying this to (14), we have
\begin{align}
\exp(\alpha t)\frac{dv}{dt} + \alpha\exp(\alpha t) v &= g\exp(\alpha t) \\
\frac{d}{dt}(\exp(\alpha t) v) &= g\exp(\alpha t) \\
\exp(\alpha t) v &= g\int \exp(\alpha t) dt \\
\exp(\alpha t) v &= g( \frac{1}{\alpha}\exp(\alpha t) + C) = \frac{g}{\alpha}\exp(\alpha t) + gC \\
v &= \frac{g}{\alpha}+ gC\exp(-\alpha t) \tag{16}
\end{align}
The initial condition is \( v(0) = 0 \) as the object is released from rest, so
\begin{align}
(0) &= \frac{g}{\alpha}+ gC\exp(-\alpha (0)) \\
(0) &= \frac{g}{\alpha}+ gC(1) \Rightarrow C = -\frac{1}{\alpha} \tag{17}
\end{align}
and the general solution is thus
\begin{equation}
v = \frac{g}{\alpha} -\frac{g}{\alpha} \exp(-\alpha t) = \frac{g}{\alpha} (1 -\exp(-\alpha t)) \tag{18}
\end{equation}
It is not hard to see that the terminal speed is \( \frac{g}{\alpha} \) as \( t \to \infty \). To reach 90% of the terminal speed at \( t = 10 \text{ s}\), we require
\begin{align}
1 -e^{-\alpha (10)} &= 0.9 \\
e^{-10\alpha} &= 0.1 \\
-10\alpha &= \ln 0.1 \\
\alpha &= \frac{\ln 10}{10} \tag{19}
\end{align}
Exercise
A water tank initially holds \( 100 \text{ kg} \) of water. A water pipe continuously supplies water to the tank at a rate of \( 5 \text{ kg/min} \). However, there is a leakage at the bottom of the tank, causing the tank to lose water at a rate of \( 0.025M \text{ kg/min} \), where \( M \) is the amount of water contained in the tank. Describe the time evolution of the mass \( M(t) \) of water in the tank with an ODE, and solve it. What is the equilibrium mass as \( t \rightarrow \infty \)? (and what is the intuition behind it?)

Answer
The required ODE is
\begin{equation}
\frac{dM}{dt} = 5 -0.025M
\end{equation}
a first-order linear ODE. The solution steps are
\begin{align}
\frac{dM}{dt} + 0.025M &= 5 \\
\frac{d}{dt}(e^{0.025t} M) = e^{0.025t}(\frac{dM}{dt} + 0.025M) &= 5e^{0.025t} \\
e^{0.025t} M &= \int 5e^{0.025t} dt = 200e^{0.025t} + C \\
M &= 200 + Ce^{-0.025t}
\end{align}
where we choose the integrating factor \( \mu = \exp(\int 0.025 dt) = e^{0.025t} \). Plugging in the initial conditions \( t = 0 \), \( M = 100 \), we have
\begin{align}
100 &= 200 + Ce^{-0.025(0)} = 200 + C \\
C &= -100
\end{align}
So the answer is
\begin{align}
M = 200 -100 e^{-0.025t} = 100 + 100 (1-e^{-0.025t})
\end{align}
The equilibrium mass as \( t \to \infty\) is \( 200 \text{ kg} \), with the rate of inflow (\( 5 \text{ kg/min} \)) balancing that of outflow (\(0.025(200) = 5 \text{ kg/min} \) also).








Leave a Reply