Mathematics, Sciences, and Technologies

“Every secret of a writer’s soul, every experience of his life, every quality of his mind is written large in his works.”
– Virginia Woolf

ODEs 1-4: More First-order ODEs Examples

,

Linear Form Involving Integration by Parts

The first example will be solving the following first-order linear ODE:

\begin{equation}
\frac{dy}{dx} + 2y = \sin x \tag{1}
\end{equation}

with the I.C. \( y(0) = 1/2 \). It has \( P(x) = 2 \) and hence the integrating factor is \( \exp(\int P(x) dx) = \exp(\int 2 dx) = e^{2x} \). Multiplying it on both sides leads to

\begin{align}
e^{2x}\frac{dy}{dx} + 2e^{2x}y &= e^{2x}\sin x \\
\frac{d}{dx}(e^{2x}y) &= e^{2x}\sin x \\
e^{2x}y &= \int e^{2x}\sin x dx \tag{2}
\end{align}

Set \( I = \int e^{2x}\sin x dx \) and this integral on the R.H.S. can be dealt with Integration by Parts (I.B.P.) in elementary Calculus. By I.B.P. twice, we can obtain

\begin{align}
I &= \int e^{2x}\sin x dx = \frac{1}{2} \int \sin x d(e^{2x}) \\
&= \frac{1}{2} [e^{2x}\sin x] -\frac{1}{2} \int e^{2x} d(\sin x) & & \text{(First I.B.P.)} \\
&= \frac{1}{2} [e^{2x}\sin x] -\frac{1}{2} \int e^{2x} \cos x dx \\
&= \frac{1}{2} [e^{2x}\sin x] -\frac{1}{4} \int \cos x d(e^{2x}) \\
&= \frac{1}{2} [e^{2x}\sin x] -\frac{1}{4} [e^{2x}\cos x] + \frac{1}{4} \int e^{2x} d(\cos x) & & \text{(Second I.B.P.)} \\
&= \frac{1}{2} [e^{2x}\sin x] -\frac{1}{4} [e^{2x}\cos x] -\frac{1}{4} \int e^{2x}\sin x dx \\
&= \frac{1}{2} [e^{2x}\sin x] -\frac{1}{4} [e^{2x}\cos x] -\frac{1}{4} I \tag{3}
\end{align}

Therefore

\begin{align}
I &= \frac{1}{2} [e^{2x}\sin x] -\frac{1}{4} [e^{2x}\cos x] -\frac{1}{4} I \\
\frac{5}{4} I &= \frac{1}{2} [e^{2x}\sin x] -\frac{1}{4} [e^{2x}\cos x] \\
I &= \frac{2}{5}e^{2x}\sin x -\frac{1}{5}e^{2x}\cos x + C \tag{4}
\end{align}

(Don’t forget to append the integration constant!) Substituting (4) back into (2) gives

\begin{align}
e^{2x}y &= \frac{2}{5}e^{2x}\sin x -\frac{1}{5}e^{2x}\cos x + C \\
y &= \frac{2}{5}\sin x -\frac{1}{5}\cos x + Ce^{-2x} \tag{5}
\end{align}

Using the I.C. yields

\begin{align}
(\frac{1}{2}) &= \frac{2}{5}(0) -\frac{1}{5}(1) + C(1) \\
\Rightarrow C &= \frac{7}{10} \tag{6}
\end{align}

So the full solution is

\begin{equation}
y = \frac{2}{5}\sin x -\frac{1}{5}\cos x + \frac{7}{10}e^{-2x} \tag{7}
\end{equation}

Logistic Population Model

The second example is the so-called Logistic Population Model in which the rate of change in population is simply given by the ODE

\begin{equation}
\frac{dN}{dt} = KN(M-N) \tag{8}
\end{equation}

where \( N = N(t) \) is the population at time \( t \), \( K \) is the natural growth factor, and \( M \) is the maximum sustainable population. \( KN \) represents the birth capacity, and \( M − N \) acts like a soft barrier to limit the population increase which corresponds to real-life restrictions like food consumption.

Now we want to solve the ODE, given that the I.C. at \( t = 0 \) is \( N(0) = M/4 \): the initial population is a quarter of the maximum population. We can approach this as a separable ODE:

\begin{align}
\frac{dN}{dt} &= KN(M-N) \\
\int \frac{dN}{N(M-N)} &= \int K dt \\
\int \frac{1}{M}(\frac{1}{N} + \frac{1}{M-N}) dN &= \int K dt \tag{9}
\end{align}

where we have utilized the partial fractions \( 1/(N(M-N)) = 1/M[1/N + 1/(M-N)] \). Continuing from (9) leads to

\begin{align}
\int \frac{1}{M}(\frac{1}{N} + \frac{1}{M-N}) dN &= \int K dt \\
\frac{1}{M} (\ln |N| -\ln |M-N|) &= Kt + C \\
\ln \left|\frac{N}{M-N}\right| &= MKt + MC \\
\left|\frac{N}{M-N}\right| &= e^{MKt + MC} \\
\frac{N}{M-N} &= \pm e^{MKt + MC} = Ae^{MKt} \tag{10}
\end{align}

where we let \( A = \pm e^{MC} \). Then

\begin{align}
N &= (M-N)A e^{MKt} \\
N (1+Ae^{MKt}) &= MAe^{MKt} \\
N &= \frac{MAe^{MKt}}{1+Ae^{MKt}} \tag{11}
\end{align}

Plugging in the I.C. \( N(0) = M/4 \) gives

\begin{align}
(\frac{M}{4}) &= \frac{MA(1)}{1+A(1)} = \frac{MA}{1+A} \\
\frac{1}{4} &= \frac{A}{1+A} \Rightarrow A = \frac{1}{3} \tag{12}
\end{align}

So the full solution is

\begin{align}
N &= \frac{M(1/3)e^{MKt}}{1+(1/3)e^{MKt}} \\
&= \frac{Me^{MKt}}{3+e^{MKt}} \tag{13}
\end{align}

Below is a schematic plot showing the case when \( K = 0.001, M = 100 \).

where the graph is a sigmoid function.

Exercise – Barometric Equation

Derive the Barometric Equation with an isothermal atmosphere (the temperature \(T = T_0\) being a constant), with the Ideal Gas Law

\begin{equation}
p = \rho R_{d}T \tag{14}
\end{equation}

and the Hydrostatic Equation
\begin{equation}
\frac{dp}{dz} = -\rho g \tag{15}
\end{equation}
where \( p \) is the pressure, \( \rho \) is the density, \( R_{d} = 287.0 \text{ J} \text{ kg}^{-1} \text{ K}^{-1} \) is the dry gas constant, and \( g = 9.81 \text{ m} \text{ s}^{-2} \) is the gravitational acceleration. You should be able to obtain
\begin{equation}
p = p_0e^{-(g/R_dT_0)z} = p_0e^{-z/H_0} \tag{16}
\end{equation}
where \( p_0 \) is the sea-level pressure. The quantity \( H_0 = R_dT_0/g \) is known as the scale height.

Then, re-do this with an atmospheric temperature profile that is linearly decreasing with height, \( T = T_0 -\Gamma z\). You should be able to get
\begin{equation}
p = p_0\left(\frac{T_0-\Gamma z}{T_0}\right)^{g/R_d\Gamma} \tag{17}
\end{equation}
If \( p_0 = 1000 \text{ hPa}\), \( T_0 = 20 \text{ }^\circ\text{C}\), and \( \Gamma = 6.5 \text{ K} \text{ km}^{-1} \), find the altitude at which the atmospheric pressure drops to \(30 \%\) of the surface value, i.e. \( 300 \text{ hPa} \), in both cases and explain the comparison based on atmospheric thermodynamics.

Answer

Combining (14) and (15):

\begin{align}
\frac{dp}{dz} &= -\rho g = -\frac{p}{R_dT_0} g \\
\int_{p_0}^p \frac{dp}{p} &= -\int_0^z \frac{g}{R_dT_0} dz \\
[\ln |p|]_{p_0}^p = \ln (\frac{p}{p_0}) &= -\frac{g}{R_dT_0}z \\
p &= p_0e^{-(g/R_dT_0)z}
\end{align}

where we have included the initial condition \( p(z=0) = p_0\) at the sea-level surface in the lower limit of integration.

For the second part, the modified hydrostatic equation is
\begin{align}
\frac{dp}{dz} &= -\frac{g}{R_d(T_0-\Gamma z)} p \\
\frac{dp}{p} &= -\frac{g}{R_d(T_0-\Gamma z)} dz
\end{align}

Integrating from the surface to some height again, we have

\begin{align}
\int_{p_0}^{p} \frac{dp}{p} &= -\int_0^z \frac{g}{R_d(T_0-\Gamma z)} dz \\
\ln |\frac{p}{p_0}| &= \frac{g}{R_d\Gamma} [\ln |T_0-\Gamma z|]_0^z \\
\ln (\frac{p}{p_0}) &= \frac{g}{R_d\Gamma} \ln(\frac{T_0-\Gamma z}{T_0}) \\
\ln (\frac{p}{p_0}) &= \ln\left\{\left(\frac{T_0-\Gamma z}{T_0}\right)^{g/R_d\Gamma}\right\} \\
p &= p_0\left(\frac{T_0-\Gamma z}{T_0}\right)^{g/R_d\Gamma}
\end{align}

Plugging in all the given values (convert the original units to SI units properly!), the pressure decreases to \( 30 \%\) of the surface value when \( z \approx 9.229 \text{ km} \) now, which is lower when compared to \( z \approx 10.326 \text{ km} \) for an isothermal atmosphere, because the decreasing temperature going up implies thinner layers.

A small extra challenge: Show that (17) is reduced to (16) in the limit of \( \Gamma \to 0 \).

Leave a Reply

I’m Benjamin

Welcome to my Mathematical World! Here you can find posts and tutorials related to applied topics like Linear Algebra, Calculus, Differential Equations, as well as Programming. Feel free to leave comments and suggestions!

Let’s connect

Discover more from Benjamin's Maths World

Subscribe now to keep reading and get access to the full archive.

Continue reading