import numpy as np
import matplotlib.pyplot as plt
'ggplot')
plt.style.use(
= np.linspace(-2, 2, 20)
x = np.linspace(-2, 2, 20)
y = np.meshgrid(x, y)
X, Y
= (X*X -Y*Y)
dy = np.ones(dy.shape)
dx
=(5, 5))
plt.figure(figsize='red')
plt.quiver(X, Y, dx, dy, color-2, -1, 0, 0], [1, -1, 2, 0], 'o', color="blue")
plt.plot([-2.2, 2.2])
plt.xlim([-2.3, 2.2])
plt.ylim([-2, 2.5, 0.5))
plt.xticks(np.arange(-2, 2.5, 0.5))
plt.yticks(np.arange('x')
plt.xlabel('y')
plt.ylabel(
plt.show()
2 First-Order Differential Equations
2.1 Solution Curves Without a Solution
- DEs can be analyzed qualitatively, allowing us to approximate a solution curve without solving the problem
- Two approaches are:
- Direction fields
- Autonomous first-order DEs
- Direction fields:
- Slope of the lineal element at \((x,y(x))\) on a solution curve is the value of \(\,\frac{dy}{dx}\,\) at this point
- Direction/slope fields of \(\,\frac{dy}{dx}=f(x,y)\,\) are collections of lineal slope elements that visually suggest the shape of a family of solution curves
For example, \(~\displaystyle\frac{dy}{dx}=\sin y\)
Using the given computer-generated direction field, sketch, by hand, an approximate solution curve that passes through each of the indicated points:
\[ \begin{aligned} \frac{df}{dx} &= x^2 -y^2 \\ \\ (a) &\;\; y(-2)=1 \\ (b) &\;\; y(-1)=-1 \\ (c) &\;\; y(0)=2 \\ (d) &\;\; y(0)=0 \end{aligned}\]
Autonomous first-order DEs, \(~\displaystyle\color{red}{\frac{dy}{dx}=f(y)}\)
An ODE in which the independent variable does not appear explicitly
\[\begin{aligned} \frac{dy}{dx} &= 1+y^2 && \mathrm{autonomous} \\ \frac{dy}{dx} &= 0.2\,xy && \mathrm{nonautonomous} \end{aligned}\]
Critical points, \(~f(c)=0\), \(~\) are constant (or equilibrium) solutions of autonomous DEs
A phase portrait is made by putting critical points on a vertical line with phase lines pointing up or down, depending on the sign of the function over intervals between the points
Some conclusions can be drawn about nonconstant solution curves to autonomous DEs
- If a solution \(y(x)\) passes through \((x_0,y_0)\) in sub-region \(R_i\), \(~\)then \(y(x)\) remains in \(R_i\)
- By continuity, \(~f(y)\) cannot change signs in a sub-region \(R_i\)
- Since \(f(y)\) is either positive or negative in \(R_i\), \(~\)a solution is either increasing or decreasing and has no relative extremum
\(~\)
Example \(\,\) Phase portrait and solution curves
\[ \displaystyle \frac{dP}{dt} = P(a-bP) \]
\(~\)
Example \(\,\) Consider the autonomous first-order differential equation
\[\frac{dy}{dx}=y^2-y^4\]
and the initial condition \(y(0)=y_0\). Sketch the graph of a typical solution \(y(x)\) when \(y_0\) has the given values
\[ \begin{aligned} &(a) && \phantom{-1 < }\; y_0 < {-1} \\ &(b) && {-1} < y_0 < 0 \\ &(c) && \phantom{-}0 < y_0 < 1 \\ &(d) && \phantom{-}1 < y_0 \\ \end{aligned}\]
2.2 Separable Equations
Consider \(~\displaystyle\frac{dy}{dx}=f(x)\)
- When \(f\) does not depend on \(y\), \(~\displaystyle\frac{dy}{dx}=f(x)\), \(~\)which can be solved by integration
- The solution \(\displaystyle y=\int f(x) dx = F(x) +c\), \(~\)where \(F(x)\) is an antiderivative (indefinite integral)
- Some functions, termed nonelementary, \(~\)do not possess an antiderivative that is an elementary function
A first-order DE of the form \(\displaystyle\frac{dy}{dx}=g(x)h(y)\) is said to be separable, or have separable variables
A separable equation can be rewritten in the form
\[ \color{red}{\frac{1}{h(y)}dy=g(x)dx}\]
which is solved by integrating both sides
\(~\)
Example \(\,\) Solve a separable equation \(\displaystyle\frac{dy}{dx}=y^2-9\), \(\;y(0)=0\)
- Separating and using partial fractions
\[ \begin{aligned} \frac{dy}{(y-3)(y+3)} &= dx \\ &\Downarrow \\ \frac{1}{6} \left [ \frac{1}{y-3} -\frac{1}{y+3} \right ] dy &= dx \end{aligned}\]
- Integrating and solving for \(y\,\) yields
\[ \begin{aligned} \frac{1}{6} \ln \left | \frac{y-3}{y+3} \right | &= x+c_1\\ &\Downarrow c=e^{6c_1} \\ y &= 3 \frac{1-ce^{6x}}{1+ce^{6x}} \end{aligned}\]
- Finally, \(~\) applying \(y(0)=0~\) gives \(c=1\)
\(~\)
Example \(\,\) Solve the given differential equation by separation of variables
\(\displaystyle \frac{dy}{dx}=\sin 5 x\)
\(\displaystyle dx +e^{3x} dy = 0\)
\(\displaystyle \frac{dy}{dx} = x\sqrt{1 -y^2}\)
\(~\)
import sympy
from sympy import pi, dsolve
sympy.init_printing()
= sympy.Symbol('x')
x = sympy.Function('y')
y
= y(x).diff(x) -x *sympy.sqrt(1 -y(x) *y(x))
eq
='separable') dsolve(eq, hint
\(\displaystyle y{\left(x \right)} = \sin{\left(C_{1} + \frac{x^{2}}{2} \right)}\)
\(~\)
Example \(\,\) Find an implicit and an explicit solution of the given initial-value problem
\(\displaystyle x^2 \frac{dy}{dx} = y -xy, \;\;y(-1)=-1\)
\(\displaystyle \frac{dx}{dt}=4(x^2 + 1), \;\;x(\pi/4)=1\)
\(~\)
= sympy.Symbol('t')
t = sympy.Function('x')
x
= x(t).diff(t) -4 *(t *t +1)
eq
={x(pi/4): 1}, hint='separable') dsolve(eq, ics
\(\displaystyle x{\left(t \right)} = \frac{4 t^{3}}{3} + 4 t - \pi - \frac{\pi^{3}}{48} + 1\)
\(~\)
2.3 Linear Equations
A first-order DE of the form \(\displaystyle a_1(x) \frac{dy}{dx} +a_0(x)y = g(x)~\) is a linear equation in the dependent variable \(y\)
The DE is homogeneous when \(g(x)=0\) ; \(~\)otherwise, \(~\)it is nonhomogeneous
The standard form of a linear DE is obtained by dividing both sides by the lead coefficient
\[\color{red}{\frac{dy}{dx}+P(x)y=f(x)}\]
The standard form equation has the property that its solution \(y\) is the sum of the solution of the associated homogeneous equation \(y_h\) and the particular solution of the nonhomogeneous equation \(y_p\) :
\[\color{red}{y=y_h +y_p}\]
- The homogeneous equation \(\displaystyle\frac{dy_h}{dx} +P(x)y_h= 0~\) is separable, allowing us to solve for \(y_h\)
\[ \begin{aligned} \frac{dy_h}{y_h} &= -P(x)dx \\ &\Downarrow \\ \ln |y_h| &= -\int P(x)\,dx +c \,\Rightarrow\, y_h = \bar{c} \exp\left( -\int P(x) \,dx \right) \end{aligned}\]
- Variation of parameters \(\,\color{blue}{y_p=u(x)y_h}~\) can be used to solve the nonhomogeneous equation of \(\,y_p\)
\[ \begin{aligned} y_h \frac{du}{dx} +& \underbrace{\left (\frac{dy_h}{dx} +P(x) y_h \right )}_{=\,0} u = f(x)\\ du &= \frac{f(x)}{y_h} dx \;\Rightarrow\; u(x) = \displaystyle\int \frac{f(x)}{y_h(x)} dx \\ &\Downarrow \\ y_p &= y_h \displaystyle\int \frac{f(x)}{y_h(x)} dx \end{aligned}\]
\(~\)
Example \(\,\) Find the general solution of the given differential equation:
\(~\displaystyle \frac{dy}{dx} + 2y=0\)
\(~\displaystyle y' +2xy=x^3\)
\(~\displaystyle x\frac{dy}{dx} +2y=3\)
\(~\displaystyle xy' +(1+x)y=e^{-x} \sin 2x\)
\(~\)
Example \(\,\) Solve the given initial-value problem. Give the largest interval \(~I\) over which the solution is defined
\(~\displaystyle y\frac{dx}{dy} -x=2y^2, \;\; y(1)=5\)
\(~\displaystyle (x+1)\frac{dy}{dx}+y = \ln x, \;\;y(1)=10\)
\(~\)
= sympy.Symbol('x')
x = sympy.Function('y')
y
= (x + 1) *y(x).diff(x) +y(x) -sympy.log(x)
eq
={y(1): 10}, hint='1st_linear') dsolve(eq, ics
\(\displaystyle y{\left(x \right)} = \frac{x \log{\left(x \right)} - x + 21}{x + 1}\)
\(~\)
Example \(\,\) The given differential equation is not linear in \(y\). \(~\)Nevertheless, find a general solution of the equation
\(~dx=(x+y^2)dy\)
\(~ydx + (2x + xy-3)dy=0\)
\(~\)
Example \(\,\) The sine integral function is defined as
\[ \mathrm{Si}(x)=\int_0^x \frac{\sin t }{t} \,dt\]
where the integrand is defined to be 1 at \(x=0\). Express the solution of the initial value problem
\[x^3 \frac{dy}{dx} + 2x^2 y = 10 \sin x, \;\; y(1)=0\]
in terms of \(\mathrm{Si}(x)\)
\(~\)
2.4 Exact Equations
A differential expression \(~M(x,y)dx + N(x,y)dy~\) is an exact differential in a region \(R\) of the \(xy\)-plane if it corresponds to the differential of some function \(f(x,y)\):
\[ \color{red}{df(x,y)=\frac{\partial f}{\partial x} dx +\frac{\partial f}{\partial y} dy}\]
and a condition of exact differentials is:
\[ \frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}\]
\(M(x,y)\,dx + N(x,y)\, dy=0 ~\) is an exact equation if the left side is an exact differential
\(~\)
Example \(\,\) Solving an exact DE, \(\;2xy\,dx+(x^2-1)\,dy=0\)
\(~\)
Integrating Factor of the first-order linear DE
\[ \begin{aligned} \frac{dy}{dx} +P(x)y &= f(x)\\ &\Downarrow \\ \left ( P(x)y -f(x) \right )dx +dy &= 0\\ &\Downarrow \times \; I(x): \text{ Integrating Factor}\\ I(x)\left ( P(x)y -f(x) \right )dx +I(x)dy &= 0 \\ \\ {\small \text{To be an exact equation }} &\big\Downarrow \\ \frac{\partial}{\partial y} \left\{I(x)\left( P(x){\color{blue}{y}} -f(x) \right) \right \} &= I(x) P(x) =\frac{d}{d x} I(x) \\ &\big\Downarrow \;\; {\color{red}{I(x) = \exp\left(\int P(x) dx\right)}} \end{aligned}\]
Then
\[ \begin{aligned} I(x) \frac{dy}{dx} +I(x) P(x)y &= I(x)f(x) \; \Rightarrow \; \frac{d} {dx}\left\{ I(x)y \right \} = I(x)f(x) \\ &\Downarrow \\ \color{red}{y(x) = I(x)^{-1}y(x_0)I(x_0)} &\color{red}{\,+\,I(x)^{-1} \int_{x_0}^x I(x) f(x) dx} \end{aligned}\]
Example \(\,\) Solve \(\displaystyle\frac{dy}{dx} -2xy = 2, \;y(0)=1\)
\[ \begin{aligned} \frac{dy}{dx} -2xy &= 2\\ &\Downarrow \times \;e^{-x^2} \\ \frac{d}{dx}[e^{-x^2}y] &= 2e^{-x^2}\\ y &= c e^{x^2} +2e^{x^2} \int_0^x e^{-t^2} dt\\ & \big\Downarrow \;{\small y(0) = 1 \rightarrow c=1} \\ y &= e^{x^2} \left[ 1 +\sqrt{\pi} \underbrace{\left(\frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt \right)}_{\mathrm{erf}(x)} \right ] \\ &= e^{x^2} \left[1 +\sqrt{\pi} \,\mathrm{erf} (x) \right] \end{aligned}\]
Example \(\,\) Determine whether the given differential equation is exact. If it is exact, solve it
\(~(2x - 1)dx + (3y+7)dy=0\)
\(~(5x + 4y)dx + (4x-8y^2)dy=0\)
\(~(2xy^2-3)dx +(2x^2y+4)dy=0\)
\(~(x^2 -y^2)dx+(x^2-2xy)dy=0\)
\(~\)
= sympy.Symbol('x')
x = sympy.Function('y')
y
= (2 *x -1) +(3 *y(x) +7) *y(x).diff(x)
eq
='1st_exact') dsolve(eq, hint
\(\displaystyle \left[ y{\left(x \right)} = - \frac{\sqrt{C_{1} - 6 x^{2} + 6 x}}{3} - \frac{7}{3}, \ y{\left(x \right)} = \frac{\sqrt{C_{1} - 6 x^{2} + 6 x}}{3} - \frac{7}{3}\right]\)
\(~\)
Example \(\,\) Solve the given initial-value problem
\(~(x+y)^2 dx + (2xy +x^2-1)dy = 0, \;\;y(1)=1\)
\(~(4y + 2t -5)dt + (6y +4t-1)dy=0, \;\;y(-1)=2\)
\(~\)
Example \(\,\) Solve the given differential equation by finding an appropriate integrating factor
- \(~y(x+y+1)dx + (x+2y)dy=0\)
2.5 Solutions by Substitutions
Substitution is often used to get a DE in a form that a known procedure can be used to find a solution
Reduction to separation of variables can be facilitated in the DE
\[\frac{dy}{dx}=f(Ax+By+C)~\]
by substituting \(\,u=Ax+By+C, \;B \neq 0\)
\(~\)
Example \(\,\) Solve the IVP \(~\displaystyle\frac{dy}{dx} = (-2x +y)^2 -7, \;y(0)=0\)
Let \(\,u=-2x+y\), then \(~\displaystyle\frac{du}{dx}=-2 + \frac{dy}{dx}~\) giving \(~\displaystyle\frac{du}{dx} = u^2 -9\)
\(~\)
= sympy.Symbol('x')
x = sympy.Function('y')
y
= y(x).diff(x) -(-2 *x +y(x))**2 +7
eq
={y(0): 0}) dsolve(eq, ics
\(\displaystyle y{\left(x \right)} = \frac{- 2 x e^{6 x} - 2 x + 3 e^{6 x} - 3}{- e^{6 x} - 1}\)
\(~\)
Homogeneous first-order DE
A first-order ordinary DE in the form:
\[\frac{dy}{dx}=f(x,y) = - \frac{M(x,y)}{N(x,y)}\]
is a homogeneous type if both function \(M(x,y)\) and \(N(x,y)\) are homogeneous functions of the same degree \(n\):
\[M(\lambda x, \lambda y) = \lambda^n M(x, y), \;\; N(\lambda x, \lambda y) = \lambda^n N(x, y)\]
Thus, we can let \(\color{blue}{t=1/x}~\) to simplify this quotient to a function \(f\) of the single variable \(y/x\):
\[\frac{M(x, y)}{N(x, y)}=\frac{M(t x,t y)}{N(t x, t y)} = \frac{M\left(1, \tfrac{y}{x}\right)}{N\left(1,\tfrac{y}{x}\right)} =-f\left(\frac{y}{x}\right) = -\frac{dy}{dx}\]
The change of variables \(y=ux\) transforms the original differential equation into the separable form:
\[\frac{du}{f(u)-u}=\frac{dx}{x}\]
Bernoulli DE:
\[~y'+P(x)y =Q(x)y^{n} \;\text{ where }\; n \neq 0~ \text{ and } n \neq 1\]
Bernoulli equations are special because they are nonlinear differential equations with known exact solutions
The substitution \(u=y^{1-n}\) reduces any Bernoulli equation to a linear differential equation
\(~\)
Example \(\,\) Solve \(\displaystyle y'-\frac{2}{x}y=-x^2y^2\)
Changing variables \(\displaystyle u=\tfrac{1}{y}\), \(~\)\(\displaystyle u'=-\tfrac{1}{y^2}y'\) gives the equation
\[ u'+\frac{2}{x}u=x^2\]
\(~\)
= sympy.Symbol('x')
x = sympy.Function('y')
y
= y(x).diff(x) -2 /x *y(x) +x**2 *y(x)**2
eq
='Bernoulli') dsolve(eq, hint
\(\displaystyle y{\left(x \right)} = \frac{5 x^{2}}{C_{1} + x^{5}}\)
\(~\)
Riccati DE
Riccati equation is any first-order ordinary differential equation that is quadratic in the unknown function. In other words, it is an equation of the form
\[y'=q_0(x)+q_1(x)y+q_2(x)y^2\]
where \(q_0(x)\neq 0\) and \(q_2(x)\neq 0\). If \(q_0(x)=0\), the equation is Bernoulli one, and if \(q_2(x)=0\), the equation is linear one
The new variable \(v=yq_2\) satisfies an equation
\[v'=v^2+R(x)v+S(x)\]
where \(S(x)=q_2 q_0\) and \(\displaystyle R(x)=q_{1}+\left({\tfrac{q_{2}'}{q_{2}}}\right)\)
Substituting \(\displaystyle v=-\tfrac{u'}{u\,}\), \(~u\) satisfies the linear 2nd order ODE
\[u''-R(x)u'+S(x)u=0\] A solution of this equation will lead to a solution \(\displaystyle y=-\tfrac{u'}{q_2u}\) of the original Riccati equation
\(~\)
Example \(\,\) Solve the given differential equation by using an appropriate substitution
\(~(x-y)dx+xdy=0\)
\(~xdx+(y-2x)dy=0\)
\(~\displaystyle \frac{dy}{dx}=\frac{y-x}{y+x}\)
\(~\displaystyle x\frac{dy}{dx}=y+\sqrt{x^2-y^2}, \;\;x>0\)
\(~\)
= sympy.Symbol('x')
x = sympy.Function('y')
y
= x *y(x).diff(x) -y(x) -sympy.sqrt(x**2 -y(x)**2)
eq
='1st_homogeneous_coeff_best') dsolve(eq, hint
\(\displaystyle y{\left(x \right)} = - x \sin{\left(C_{1} - \log{\left(x \right)} \right)}\)
\(~\)
Example \(\,\) Solve the given initial-value problem
\(~\displaystyle xy^2 \frac{dy}{dx}=y^3-x^3, \;\;y(1)=2\)
\(~\displaystyle (x^2 +2y^2) \frac{dx}{dy}=xy, \;\; y(-1)=1\)
\(~\)
Example \(\,\) Solve the given differential equation by using an appropriate substitution
\(~\displaystyle x\frac{dy}{dx} +y =\frac{1}{y^2}\)
\(~\displaystyle 3(1+t^2)\frac{dy}{dt}=2ty(y^3-1)\)
\(~\displaystyle \frac{dy}{dx}=\cos (x+y), \;\;y(0)=\frac{\pi}{4}\)
\(~\)
2.6 A Numerical Method
Numerical method: \(\,\) an algorithm for approximating the unknown solution to a DE
- Linearization approximates solutions within a small area around lineal elements in direction fields
- The procedure of evaluating successive tangent lines is \(~\)Euler’s method
Example \(\,\) Consider \(y'=0.1\sqrt{y}+0.4x^2, \;y(2)=4~\) and approximate \(y(2.5)\) using \(h=0.1\)
Substituting into the general formula for Euler’s method gives
\[y_{n+1}=y_n +h\left(0.1\sqrt{y_n} + 0.4x_n^2 \right)\]
Considering the initial condition and \(n=0\)
\[\scriptsize \begin{aligned} y_1 &= 4+0.1\left( 0.1\sqrt{4} + 0.4 \cdot2^2\right ) =4.1800 \\ y_2 &= 4.18 +0.1\left( 0.1\sqrt{4.18} + 0.4 \cdot2.1^2\right ) =4.3768 \\ &\, \vdots \\ y_5 &= 5.0768 \end{aligned}\]
= 2.0
x0 = 4.0
y0 = 2.5
xf
= 0.1
h = int((xf -x0) /h) + 1
n
= np.linspace(x0, xf, n)
x = np.zeros(n)
y
0] = y0
y[for i in range(1, n):
= y[i -1] +h *(0.1 *np.sqrt(y[i -1]) +0.4 *x[i -1]**2)
y[i] print(f'x = {x[i]: 3.1f}, y = {y[i]: 5.4f}')
=(4, 4))
plt.figure(figsize'o')
plt.plot(x, y, "$x$")
plt.xlabel("$y$")
plt.ylabel("$h=0.1$")
plt.title(
plt.show()
x = 2.1, y = 4.1800
x = 2.2, y = 4.3768
x = 2.3, y = 4.5914
x = 2.4, y = 4.8244
x = 2.5, y = 5.0768
Example \(\,\) Use Euler’s method to obtain a four-decimal approximation of the indicated value. Carry out the recursion, first using \(h=0.1\) and then using \(h=0.05\)
\[~y'=2x-3y+1, \;\; y(1)=5; \;\;y(1.2)\]
2.7 Linear Models
Example \(\,\) Series Circuits - For a series circuit containing a resister \(R\) and an inductor \(L\),
\(~\)
Kirchoff’s second law gives
\[L\frac{di}{dt}+Ri=E(t)\]
For a series circuit containing a resister and a capacitor,
Kirchoff’s second law gives
\[Ri+\frac{1}{C}q=E(t)\]
where \(\displaystyle i=\frac{dq}{dt}\). \(~\)Then \(~\)\(\displaystyle R\frac{dq}{dt}+\frac{1}{C}q=E(t)\)
\(~\)
Example \(\,\) The population of a community is known to increase at a rate proportional to the number of people present at time \(t\). If an initial population \(P_0\) has doubled in 5 years, how long will it take to triple? To quadruple?
2.8 Nonlinear Models
\(~\)
Example \(\,\) The logistic model
Verhulst proposed a model, called the logistic model, for population growth in 1838. It does not assume unlimited resources. Instead, it assumes there is a carrying capacity \(K\) for the population
This carrying capacity is the stable population level. If the population is above \(K\), then the population will decrease, but if below, then it will increase
For this model, it is assumed that ther rate of change \(\frac{dy}{dt}\) of the population \(y\) is proportional to the product of the current population \(y\) and \(K − y\)
\[\frac{dy}{dt}=\alpha y(K-y)\]
2.9 Modeling with Systems of First-Order DEs
\(~\)
Example \(\,\) Radioactive Series:
\[X \xrightarrow{k_1} Y \xrightarrow{k_2} Z\]
The decay of the initial element \(X\) is described by
\[\frac{dx}{dt}=-k_1 x\]
The second element \(Y\) is produced by the decay of \(X\) and loses from its own spontaneous decay
\[\frac{dy}{dt}=k_1 x -k_2 y\]
The stable element \(z\) is generated from the decay of \(Y\)
\[\frac{dz}{dt}=k_2 y\]
\(~\)
Example \(\,\) Consider the Lotka-Volterra predator-prey model defined by
\[ \begin{aligned} \frac{dx}{dt} &= -0.1x +0.02xy \\ \frac{dy}{dt} &= 0.2y -0.025xy \end{aligned}\]
where the populations \(x(t)\) (predator) and \(y(t)\) (prey) are measured in the thousands and \(x(0)=6\) and \(y(0)=6\)
- Use a numerical solver to graph \(x(t)\) and \(y(t)\)
# Lotka-Volterra predator-prey model
from scipy import integrate
= -0.1, 0.02, 0.2, -0.025
a, b, c, d
def f(t, xy):
= xy
x, y return [a *x +b *x *y, c *y +d *x *y]
# Initial condition and Time span
= [6, 6]
xy0 = 400
tf = np.linspace(0, tf, 5*tf)
t_eval
# Numerical Solver
= integrate.solve_ivp(f, [0, tf], xy0, t_eval=t_eval)
sol
= sol.t
t = sol.y.T xy_t
- Use the graphs to approximate the period of each population
= plt.subplots(1, 1, figsize=(6, 5))
fig, ax
0], 'r', label="Predator")
ax.plot(t, xy_t[:, 1], 'b', label="Prey")
ax.plot(t, xy_t[:,
"Time")
ax.set_xlabel("Number of animals")
ax.set_ylabel(0, tf)
ax.set_xlim(0, 12)
ax.set_ylim(
ax.legend()
plt.show()
Worked Exercises
Solve the given differential equation by separation of variables
2.2: 1. \(\,\displaystyle \frac{dy}{dx}=\sin 5 x\)
Solution
\[ \begin{aligned} \frac{dy}{dx} &=\sin 5x\\ &\Downarrow \\ dy &= \sin 5x \,dx \\ &\Downarrow \\ y &=-\frac{1}{5} \cos 5x +c \end{aligned}\]
2.2: 3. \(\,\displaystyle dx +e^{3x} dy = 0\)
Solution
\[ \begin{aligned} dy &=-e^{-3x} \,dx\\ &\Downarrow \\ y &= \frac{1}{3}e^{-3x} +c \end{aligned}\]
2.2: 21. \(\,\displaystyle \frac{dy}{dx} = x\sqrt{1 -y^2}\)
Solution
\[ \begin{aligned} \frac{1}{\sqrt{1 -y^2}}dy &= x \,dx\\ &\Downarrow \\ \arcsin y &= \frac{1}{2}x^2 +c \\ &\Downarrow \\ y &= \sin \left(\frac{1}{2}x^2 +c \right) \end{aligned}\]
2.2: 25. Find an implicit or an explicit solution of the given initial-value problem
\[ x^2 \frac{dy}{dx} = y -xy, \;\;y(-1)=-1\]
Solution
\[ \begin{aligned} \frac{1}{y}dy &= \frac{1-x}{x^2} \,dx\\ &\Downarrow \\ \ln |y| &= -\left(\frac{1}{x} +\ln |x| \right) +c \\ &\Downarrow {\small y(-1)=-1 \; \Rightarrow \; c=-1}\\ \ln |y| &= -\left(1 +\frac{1}{x} \right) -\ln |x| \\ &\Downarrow \\ y &= \frac{1}{x} e^{-\left( 1 +\frac{1}{x}\right)} \end{aligned}\]
2.7: 41. \(\,\) Evaporating Raindrop \(\,\) As a raindrop falls, it evaporates while retaining its spherical shape. If we make the further assumptions that the rate at which the raindrop evaporates is proportional to its surface area and that air resistance is negligible, then a model for the velocity \(v(t)\) of the raindrop is
\[ \frac{dv}{dt} + \frac{3(k/\rho)}{(k/\rho) t +r_0} v = g \]
Here \(\rho\) is the density of water, \(r_0\) is the radius of the raindrop at \(t=0\), \(k < 0\) is the constant of proportionality \(\displaystyle \frac{dm}{dt}=4\pi r^2 k\), and the downward direction is taken to be the positive direction
(a)\(\,\) Solve for \(v(t)\) if the raindrop falls from the rest
(b)\(\,\) Show that the radius of the raindrop at time \(t\) is \(r(t)=(k/\rho)t +r_0\)
(c)\(\,\) If \(r_0=0.01\) ft and \(r =0.007\) ft at time \(t=10\) sec after the raindrop falls from a cloud, determine the time at which the raindrop has evaporated completely
Solution
(a)\(\,\)
\[ \begin{aligned} \frac{dv}{dt} &+ \frac{3(k/\rho)}{(k/\rho) t +r_0} v = g \\ &\Downarrow {\small \text{ multiply by the integral factor }} \\ \frac{d}{dt} \left[ \left(\frac{k}{\rho}t +r_0 \right)^3 v \right] &= \left(\frac{k}{\rho}t +r_0 \right)^3 g\\ &\Downarrow \\ v(t)=\frac{g\rho}{4k} \left( \frac{k}{\rho} t +r_0 \right) &+c\left(\frac{k}{\rho}t +r_0 \right)^{-3} \\ &\Downarrow {\small \text{ } v(0)=0 \; \rightarrow \;c = -\frac{g\rho}{4k} r_0^4} \\ v(t) = \frac{g\rho}{4k} \left(\frac{k}{\rho}t +r_0 \right) & \left[ 1 - \left( \frac{r_0}{ \frac{k}{\rho}t +r_0 } \right)^4 \right] \\ \end{aligned}\]
(b)\(\,\)
\[ \begin{aligned} m &= \frac{4}{3}\pi r^3 \rho\\ &\Downarrow \\ \frac{dm}{dt} &= 4\pi r^2 \rho \frac{dr}{dt}\\ &\Downarrow \text{ } {\scriptstyle \frac{dm}{dt}=4\pi r^2 k}\\ \frac{dr}{dt} &= \frac{k}{\rho} \\ &\Downarrow \text{ } {\scriptstyle r=r_0 \text{ at } t=0} \\ r(t) &= \frac{k}{\rho} t +r_0 \end{aligned}\]
(c)\(\,\)
\[ \begin{aligned} r(10) &= \frac{k}{\rho} \times 10 +0.01 =0.007 \; \Rightarrow \; \frac{k}{\rho} = -0.0003\\ &\Downarrow \\ r(t) &= -0.0003 t + 0.01 = 0 \; \Rightarrow \; t =\frac{0.01}{0.0003} \approx 33.3 \;\text{sec} \end{aligned}\]