Académique Documents
Professionnel Documents
Culture Documents
x
1
(t)
x
2
(t)
.
.
.
x
n
(t)
, A(t) =
a
11
(t) a
12
(t) . . . a
1n
(t)
a
21
(t) a
22
(t) . . . a
2n
(t)
.
.
.
.
.
. . . .
.
.
.
a
n1
(t) a
n2
(t) . . . a
nn
(t)
, and F(t) =
f
1
(t)
f
2
(t)
.
.
.
f
n
(t)
.
Homogeneous Linear Systems
The corresponding homogeneous system of equation (6.28) is
X
= AX. (6.29)
In the same way as with the previously discussed linear equations, a general solu-
tion of (6.28) is X = X
h
+ X
p
where X
h
is a general solution of (6.29) and X
p
is a
particular solution of the nonhomogeneous system (6.28). A particular solution to a
system of ordinary
differential equations is a set
of functions that satisfy the
system but do not contain
any arbitrary constants. That
is, a particular solution to a
system is a set of specic
functions, containing no
arbitrary constants, that satisfy
the system.
If
1
,
2
, . . . ,
n
are n linearly independent solutions of (6.29), a general
solution of (6.29) is
X = c
1
1
+c
2
2
+ +c
n
n
=
1
2
n
c
1
c
2
.
.
.
c
n
= C,
where
=
1
2
n
and C =
c
1
c
2
.
.
.
c
n
.
is called a fundamental matrix for (6.29). If is a fundamental matrix for (6.29),
= A or
A = 0.
After loading the DEtools package and dening A, the command
matrixDE(A,t)
attempts to nd a fundamental matrix for (6.29).
488 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
A(t) constant
Suppose that A(t) = A has constant real entries. Let be an eigenvalue of A with
corresponding eigenvector v. Then, ve
t
is a solution of X
= AX.
If = + i, = 0, is an eigenvalue of A and has corresponding eigenvector
v = a +bi, two linearly independent solutions of X
= AX are
e
t
_
a cos t bsin t
_
and e
t
_
a sin t +bcos t
_
. (6.30)
EXAMPLE 6.4.1: Solve each of the following systems: (a) X
=
_
1/2 1/3
1/3 1/2
_
X; (b)
_
x
=
1
2
y
y
=
1
8
x
; (c)
_
dx/dt =
1
4
x + 2y
dy/dt = 8x
1
4
y
.
SOLUTION: (a) With eigenvects, which is contained in the linalg
package, we see that the eigenvalues and eigenvectors of A =
_
1/2 1/3
1/3 1/2
_
are
1
= 1/6 and
2
= 5/6 and v
1
=
_
1
1
_
and
v
2
=
_
1
1
_
, respectively.
> with(linalg):
> with(DEtools):
> A:=matrix(2,2,[-1/2,-1/3,-1/3,-1/2]);
A := matrix
_
[[1/2, 1/3], [1/3, 1/2]]
_
> eigenvects(A);
[1/6, 1, {vector ([1, 1])}], [5/6, 1, {vector ([1, 1])}]
Then X
1
=
_
1
1
_
e
t/6
and X
2
=
_
1
1
_
e
5t/6
are two lin-
early independent solutions of the system so a general solution
is X =
_
e
t/6
e
5t/6
e
t/6
e
5t/6
__
c
1
c
2
_
; a fundamental matrix is =
_
e
t/6
e
5t/6
e
t/6
e
5t/6
_
, which we conrm using matrixDE.
> matrixDE(A,t);
_
matrix
_
[[e
1/6 t
, e
5/6 t
], [e
1/6 t
, e
5/6 t
]]
_
, vector ([0, 0])
_
6.4 Systems of Equations 489
y(t)
1
0.5
0
-0.5
-1
x(t)
1 0.5 0 -0.5 -1
Figure 6-27 Direction eld for X
= AX
We use dsolve to nd a general solution of the system by entering
> gensol:=dsolve(diff(x(t),t)=-1/2*x(t)-1/3*y(t),
diff(y(t),t)=-1/3*x(t)-1/2*y(t),x(t),y(t));
gensol :=
x(t) =_C1e
5/6t
+_C2e
1/6t
, y(t) =_C1e
5/6t
_C2e
1/6t
= f (x, y), y
= g(x, y)}
for a x b and c y d.
> DEplot([diff(x(t),t)=-1/2*x(t)-1/3*y(t),diff(y(t),t)
=-1/3*x(t)-1/2*y(t)],
> [x(t),y(t)],t=-1..1,x=-1..1,y=-1..1,scene=[x(t),
> y(t)],scaling=CONSTRAINED,color=BLACK);
Several solutions are also graphed with DEplot and shown together
with the direction eld in Figure 6-28.
> ivals:=seq(-1+.25*i,i=0..8):
> i1:=seq([x(0)=1,y(0)=i],i=ivals):
> i2:=seq([x(0)=i,y(0)=1],i=ivals):
> i3:=seq([x(0)=-1,y(0)=i],i=ivals):
> i4:=seq([x(0)=i,y(0)=-1],i=ivals):
490 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
y(t)
1
0.5
0
-0.5
-1
x(t)
1 0.5 0 -0.5 -1
Figure 6-28 Direction eld for X
0 1/2
1/8 0
0 1/2
1/8 0
are
1,2
= 0
1
4
i and
v
1,2
=
1
0
0
1/2
i.
> A:=matrix(2,2,[0,1/2,-1/8,0]);
A := matrix
> eigenvects(A);
[1/4 i, 1,
vector
[1, 1/2 i]
], [1/4 i, 1,
vector
[1, 1/2 i]
]
Two linearly independent solutions are then X
1
=
1
0
cos
1
4
t
0
1/2
sin
1
4
t =
cos
1
4
t
1
2
sin
1
4
t
and X
2
=
1
0
sin
1
4
t +
0
1/2
cos
1
4
t
=
sin
1
4
t
1
2
cos
1
4
t
cos
1
4
t sin
1
4
t
1
2
sin
1
4
t
1
2
cos
1
4
t
c
1
c
2
or x = c
1
cos
1
4
t + c
2
sin
1
4
t and y
= c
1
1
2
sin
1
4
t +
1
2
c
2
cos
1
4
t.
> matrixDE(A,t);
[matrix
[[cos
1/4 t
, sin
1/4 t
], [1/2 sin
1/4 t
,
1/2 cos
1/4 t
]]
1/4 t
1/4 t
, x (t)
= _C1 sin
1/4 t
+ _C2 cos
1/4 t
Initial-value problems for systems are solved in the same way as for
other equations. For example, entering
> partsol:=dsolve(diff(x(t),t)=1/2*y(t),diff(y(t),t)
=-1/8*x(t),x(0)=1,y(0)=-1,x(t),y(t));
partsol :=
y (t) = cos
1/4 t
1/2 sin
1/4 t
, x (t) = 2 sin
1/4 t
+ cos
1/4 t
1
4
2
8
1
4
1
4
2
8
1
4
are found to be
1,2
=
1
4
4i and v
1,2
=
0
2
1
0
i with
eigenvects.
> A:=matrix(2,2,[-1/4,2,-8,-1/4]):
> eigenvects(A);
[1/4 + 4 i, 1, {vector ([1, 2 i])}], [1/4 4 i, 1, {vector ([1, 2 i])}]
6.4 Systems of Equations 493
A general solution is then
X = c
1
X
1
+c
2
X
2
= c
1
e
t/4
__
1
0
_
cos 4t
_
0
2
_
sin 4t
_
+c
2
e
t/4
__
1
0
_
sin 4t +
_
0
2
_
cos 4t
_
= e
t/4
_
c
1
_
cos 4t
2 sin 4t
_
+c
2
_
sin 4t
2 cos 4t
__
= e
t/4
_
cos 4t sin 4t
2 sin 4t 2 cos 4t
__
c
1
c
2
_
or x = e
t/4
(c
1
cos 4t +c
2
sin 4t) and y = e
t/4
(2c
2
cos 4t 2c
1
sin 4t).
> matrixDE(A,t);
_
matrix
_
[[e
1/4 t
cos
_
4 t
_
, e
1/4 t
sin
_
4 t
_
_
,
_
2 e
1/4 t
sin
_
4 t
_
, 2 e
1/4 t
cos
_
4 t
_
]]
_
, vector
_
[0, 0]
_
_
We conrm this result using dsolve.
> dsolve(diff(x(t),t)=-1/4*x(t)+2*y(t),diff(y(t),t)
=-8*x(t)-1/4*y(t),
> x(t),y(t));
_
y (t) = 2 e
1/4 t
(_C1 cos (4 t) +_C2 sin (4 t)) ,
x (t) = e
1/4 t
(_C1 sin (4 t) +_C2 cos (4 t))
_
We use DEplot to graph the direction eld associated with the system
along with various solutions in Figure 6-31.
> ivals:=seq(-1+.25*i,i=0..8):
> i1:=seq([x(0)=1,y(0)=i],i=ivals):
> i2:=seq([x(0)=i,y(0)=1],i=ivals):
> i3:=seq([x(0)=-1,y(0)=i],i=ivals):
> i4:=seq([x(0)=i,y(0)=-1],i=ivals):
> DEplot([diff(x(t),t)=-1/4*x(t)+2*y(t),diff(y(t),t)
=-8*x(t)-1/4*y(t)],
> [x(t),y(t)],t=0..10,[i1,i2,i3,i4],x=-1..1,y=-1..1,
scene=[x(t),y(t)],
> scaling=CONSTRAINED,color=GRAY,linecolor=BLACK,
thickness=1,
> stepsize=.05);
494 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
y(t)
1
0.5
0
-0.5
-1
x(t)
1 0.5 0 -0.5 -1
Figure 6-31 Various solutions and direction eld associated with the system
Last, we illustrate how to solve an initial-value problem and graph the
resulting solutions by nding the solution that satises the initial condi-
tions x(0) = 100 and y(0) = 10 and then graphing the results with plot
in Figure 6-32.
> x:=x:y:=y:
> partsol:=dsolve(diff(x(t),t)=-1/4*x(t)+2*y(t),
> diff(y(t),t)=-8*x(t)-1/4*y(t),x(0)=100,y(0)=10,x(t),
y(t));
> assign(partsol):
> plot([x(t),y(t)],t=0..20,color=[BLACK,GRAY]);
> plot([x(t),y(t),t=0..20],color=BLACK);
partsol :=
y (t) = 2 e
1/4 t
(5 cos (4 t) +100 sin (4 t)) , x (t)
= e
1/4 t
(5 sin (4 t) +100 cos (4 t))
(m
1
+m
2
) l
1
2
d
2
1
dt
2
+m
2
l
1
l
2
d
2
2
dt
2
+(m
1
+m
2
) l
1
g
1
= 0
m
2
l
2
2
d
2
2
dt
2
+m
2
l
1
l
2
d
2
1
dt
2
+m
2
l
2
g
2
= 0
using the approximation sin for small displacements.
1
represents the dis-
placement of the upper pendulumand
2
that of the lower pendulum. Also, m
1
and
6.4 Systems of Equations 495
t
20 15 10 5 0
150
(a) (b)
100
50
0
-50
-100
-150
150
100
50
0
-50
-100
-150
80 40 0 -40 -80
Figure 6-32 (a) Graph of x(t) and y(t). (b) Parametric plot of x(t) versus y(t)
m
2
represent the mass attached to the upper and lower pendulums, respectively,
while the length of each is given by l
1
and l
2
.
EXAMPLE 6.4.2: Suppose that m
1
= 3, m
2
= 1, and each pendulumhas
length 16. If
1
(0) = 1,
1
(0) = 0,
2
(0) = 1, and
2
4 16
2
d
2
1
dt
2
+16
2
d
2
2
dt
2
+4 16 32
1
= 0
16
2
d
2
2
dt
2
+16
2
d
2
1
dt
2
+16 32
2
= 0
,
which we simplify to obtain
4
d
2
1
dt
2
+
d
2
2
dt
2
+8
1
= 0
d
2
2
dt
2
+
d
2
1
dt
2
+2
2
= 0
.
First, we use dsolve to solve the initial value problem.
> Eq1:=4*diff(theta[1](t),t$2)+diff(theta[2](t),t$2)+
> 8*theta[1](t)=0:
496 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
2
(a) (b)
0
1
20
t
15 5
-2
-1
0 10
2
1
0
-2
1 0.5
-1
-0.5 0 -1
Figure 6-33 (a)
1
(t) (in black) and
2
(t) (in gray) as functions of t. (b) Parametric plot of
1
(t) versus
2
(t)
> Eq2:=diff(theta[1](t),t$2)+diff(theta[2](t),t$2)+
> 2*theta[2](t)=0:
To solve the initial-value problem using traditional methods, we use
the method of Laplace transforms. To do so, we dene sys to be the The Laplace transform of
y = f (t) is F(s)=L
f (t)
0
e
st
f (t) dt.
system of equations and then use dsolve together with the option
method=laplace to compute the Laplace transform of each equation.
> sola:=dsolve(Eq1,Eq2,theta[1](0)=1,D(theta[1])(0)=0,
theta[2](0)=1,
> D(theta[2])(0)=0,theta[1](t),theta[2](t),
method=laplace);
sola :=
1
(t) = 1/4 cos (2 t) +3/4 cos
2/3
3t
,
2
(t)
= 3/2 cos
2/3
3t
1/2 cos (2 t)
These two functions are graphed together in Figure 6-33(a) and para-
metrically in Figure 6-33(b).
> assign(sola):
> plot([theta[1](t),theta[2](t)],t=0..20,
color=[BLACK,GRAY]);
> plot([theta[1](t),theta[2](t),t=0..20],color=BLACK);
We can illustrate the motion of the pendulum as follows. First, we
dene the function pen2.
> pen2:=proc(t0,len1,len2)
> local pt1,pt2,xt0,yt0;
6.4 Systems of Equations 497
> xt0:=evalf(subs(t=t0,theta[1](t)));
> yt0:=evalf(subs(t=t0,theta[2](t)));
> pt1:=[len1*cos(3*Pi/2+xt0),len1*sin(3*Pi/2+xt0)];
> pt2:=[len1*cos(3*Pi/2+xt0)+len2*cos(3*Pi/2+yt0),
> len1*sin(3*Pi/2+xt0)+len2*sin(3*Pi/2+yt0)];
> plot([[0,0],pt1,pt2],xtickmarks=2,ytickmarks=2,
> view=[-32..32,-32..0]);
> end:
Next, we dene ivals to be a list of 16 evenly spaced numbers between
0 and10. seqis then usedto apply pen2to the list of numbers inivals.
The resulting set of graphics is displayed as an array using display
with the option insequence=true in Figure 6-34.
> with(plots):
> ivals:=[seq(10*i/15,i=0..15)]:
0.
-.2e2
0. -2.
0.
-.1e2
0.
0.
.1e2
-.2e2
0.
-.1e2
0. -.2e2
0.
0.
-.2e2
-.2e2
0.
-.2e2 4.
0.
0.
-.2e2
0. -.1e2
0.
0.
-.2e2
-.1e2
-.2e2
2. 0.
0.
-2.
-.1e2
0. -.2e2
0.
-.2e2
0. -.1e2
0.
0.
-.2e2
-.2e2
.2e2
4. 2.
0.
0.
0.
-.2e2
.2e2 0.
0.
-.1e2
0.
.2e2
-.1e2
0.
.2e2 0.
0.
-.1e2
.1e2 0.
Figure 6-34 The double pendulum for 16 equally spaced values of t between 0 and 10
498 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
> toshow:=[seq(pen2(i,16,16),i=ivals)]:
> nops(toshow);
16
> anarray:=display(toshow,insequence=true):
> display(anarray);
We can also use displayto generate an animation. We showone frame
from the animation that results from the following command.
> display(toshow,insequence=true);
0
-20
0
U+U
.
Substituting into (6.28) results in
U+U
= AU+F
U
= F
U
=
1
F
U =
1
F dt,
where we have used the fact that
UAU =
U = 0. It follows that
X
p
=
1
F dt. (6.31)
A general solution is then
X = X
h
+X
p
= C +
1
F dt
=
C +
1
F dt
1
F dt,
where we have incorporated the constant vector C into the indenite integral
1
F dt.
EXAMPLE 6.4.3: Solve the initial-value problem
X
1 1
10 1
t cos 3t
t sin t +t cos 3t
, X(0) =
1
1
.
Remark. In traditional form, the system is equivalent to
= x y t cos 3t
y
h
=
1 1
10 1
X
h
. The eigenvalues and corresponding eigenvectors of A =
1 1
10 1
are
1,2
= 3i and v
1,2
=
1
10
3
0
i, respectively.
> with(linalg):
> with(DEtools):
> A:=matrix(2,2,[1,-1,10,-1]):
> eigenvects(A);
[3 i, 1, {vector ([1, 1 3 i])}] , [3 i, 1, {vector ([1, 1 + 3 i])}]
A fundamental matrix is =
sin 3t cos 3t
sin 3t 3 cos 3t cos 3t + 3 sin 3t
> fm:=matrixDE(A,t);
fm := [matrix ([[sin (3 t) , cos (3 t)], [sin (3 t) 3 cos (3 t) , cos (3 t) ,
+3 sin (3 t)]]) vector ([0, 0])]
> fm[1];
matrix ([[sin (3 t) , cos (3 t)], [sin (3 t) 3 cos (3 t) , cos (3 t) + 3 sin (3 t)]])
> fminv:=simplify(inverse(fm[1]));
We now compute
1
F(t)
> ft:=matrix(2,1,[-t*cos(3*t),-t*sin(t)-t*cos(3*t)]);
t cos (3 t)
t sin (t) t cos (3 t)
and
1
F(t) dt.
For length considerations, we
display only the nal results.
To see each result as it is
generated, replace the colons
with semi-colons. > step2:=map(int,step1,t):
6.4 Systems of Equations 501
A general solution of the nonhomogeneous system is then
__
1
F(t) dt +C
_
.
> simplify(evalm(fm[1] &* step2)):
It is easiest to use matrixDE
> check1:=matrixDE(A,ft,t):
> check1[1];
_
cos (3t) sin (3t)
cos (3t) +3 sin (3t) sin (3t) 3 cos (3t)
_
> check1[2];
_
1
72
cos (3t) 1/32 cos (t) 1/12 sin (3t) t 1/4 cos (3t) t
2
+1/8t sin (t) ,
1
72
cos (3t) 1/32 cos (t) 1/12 sin (3t) t 1/4 cos (3t) t
2
+1/8t sin (t) +1/24 sin (3t)
5
32
sin (t) +3/4t cos (3t) 3/4 sin (3t) t
2
+
23
8
t cos (t) 4t (cos (t))
3
_
or dsolve to solve the initial-value problem directly.
> check2:=dsolve(diff(x(t),t)=x(t)-y(t)-t*cos(3*t),
> diff(y(t),t)=10*x(t)-y(t)-t*sin(t)-t*cos(3*t),x(0)=1,y(0)=-1,
> x(t),y(t));
check2 :=
_
y (t) =
31
32
cos (3 t) +
123
32
sin (3 t)
5
32
sin (t) 1/4 t cos (3 t) 1/8 t cos (t)
3/4 sin (3 t) t
2
1/12 sin (3 t) t +1/8 t sin (t) 1/32 cos (t) 1/4 cos (3 t) t
2
,
x (t) = 2/3 sin (3 t) +
33
32
cos (3 t) 1/12 sin (3 t) t +1/8 t sin (t)
1/32 cos (t) 1/4 cos
_
3 t
_
t
2
_
The solutions are graphed with plot in Figure 6-35.
> assign(check2):
> plot([x(t),y(t)],t=0..8*Pi,color=[BLACK,GRAY]);
> plot([x(t),y(t),t=0..8*Pi],color=BLACK,scaling=CONSTRAINED);
x
2
1
= y
y
= x
x
2
1
y.
(6.32)
If = 2/3, x(0) = 1, and y(0) = 0, (a) nd x(1) and y(1). (b) Graph the
solution that satises these initial conditions.
SOLUTION: We use dsolve with the numeric option to solve (6.32)
with = 2/3 subject to x(0) = 1 and y(0) = 0. We name the resulting
numerical solution numsol.
> with(plots):
> numsol:=dsolve([diff(x(t),t)=y(t),diff(y(t),t)=-x(t)
-2/3*(x(t)2-1)*y(t),
> x(0)=1,y(0)=0],[x(t),y(t)],numeric);
Warning, the name changecoords has been redefined
numsol := proc(x
r
kf 45)...endproc
We evaluate numsol if t = 1 to see that x(1) .5128 and y(1) .9692.
> numsol(1);
[t = 1.0, x (t) = 0.512847902997304538, y (t) = 0.969203620640395002]
odeplotis usedtographx(t) andy(t) together inFigure 6-36(a); a three-
dimensional plot, (t, x(t), y(t)), is shown in Figure 6-36(b); a parametric
plot is shown in Figure 6-36(c); and the limit cycle is shown more clearly
in Figure 6-36(d) by graphing the solution for 20 t 30.
> odeplot(numsol,[[t,x(t)],[t,y(t)]],0..15,numpoints
=200);
> odeplot(numsol,[t,x(t),y(t)],0..15,axes=BOXED,
numpoints=200);
> odeplot(numsol,[x(t),y(t)],0..15,numpoints=200);
> odeplot(numsol,[x(t),y(t)],20..30,numpoints=200);
= f
1
(x
1
, x
2
, . . . , x
n
)
x
2
= f
2
(x
1
, x
2
, . . . , x
n
)
.
.
.
x
n
= f
n
(x
1
, x
2
, . . . , x
n
) .
(6.33)
An equilibrium (or rest) point, E = (x
1
, x
2
, . . . , x
n
f
1
x
1
f
1
x
2
. . .
f
1
x
n
f
2
x
1
f
2
x
2
. . .
f
2
x
n
.
.
.
.
.
. . . .
.
.
.
f
n
x
1
f
n
x
2
. . .
f
n
x
n
.
Use the jacobian function, which is contained in the linalg package, to
compute the Jacobian matrix for a set of functions.
The rest point, E, is locally stable if and only if all the eigenvalues of J(E) have
negative real part. If E is not locally stable, E is unstable.
EXAMPLE 6.4.5 (Dufngs Equation): Consider the forced pendu-
lum equation with damping,
x
+kx
1
7!
x
7
+ .
Using sin x x, (6.35) reduces to the linear equation x
+kx
+x = F(t).
On the other hand, using the approximation sin x x
1
6
x
3
, we
obtain x
+kx
x
1
6
x
3
+kx
+cx +x
3
= F cos t, (6.36)
where k and c are positive constants.
Let y = x
. Then, y
= x
= F cos t kx
cx x
3
= F cos t ky
cx x
3
and we can write (6.36) as the system
x
= y
y
= F cos t ky cx x
3
.
(6.37)
Assuming that F = 0 results in the autonomous system
x
= y
y
= cx x
3
ky.
(6.38)
The rest points of system (6.38) are found by solving
x
= y
y
= cx x
3
ky,
resulting in E
0
= (0, 0).
> with(DEtools):
> with(linalg):
> solve(y=0,-c*x-epsilon*x3-k*y=0,x,y);
y = 0, x = 0
y = 0, x = RootOf
c + _Z
2
, label = _L1
0 1
c 3 x
2
k
> s2:=subs(x=0,eval(s1));
0 1
c k
k
2
4 c, 1/2 k 1/2
k
2
4 c
Because k and c are positive, k
2
4c < k
2
so the real part of each
eigenvalue is always negative if k
2
4c = 0. Thus, E
0
is locally stable.
For the autonomous system
x
= f (x, y)
y
= g(x, y),
(6.39)
Bendixsons theorem states that if f
x
(x, y)+g
y
(x, y) is a continuous func-
tion that is either always positive or always negative in a particular
region R of the plane, then system (6.39) has no limit cycles in R. For
(6.38) we have
d
dx
+
d
dy
cx x
3
ky
= k,
which is always negative. Hence, (6.38) has no limit cycles andit follows
that E
0
is globally, asymptotically stable.
> diff(y,x)+diff(-c*x-epsilon*x3-k*y,y);
k
We use DEplot to illustrate two situations that occur. In Figure 6-37(a),
we use c = 1, = 1/2, and k = 3. In this case, E
0
is a stable node. On the
other hand, in Figure 6-37(b), we use c = 10, = 1/2, and k = 3. In this
case, E
0
is a stable spiral.
> ivals:=seq(-2.5+.5*i,i=0..10):
> i1:=seq([x(0)=2.5,y(0)=i],i=ivals):
> i2:=seq([x(0)=i,y(0)=2.5],i=ivals):
> i3:=seq([x(0)=-2.5,y(0)=i],i=ivals):
> i4:=seq([x(0)=i,y(0)=-2.5],i=ivals):
> DEplot([diff(x(t),t)=y(t),diff(y(t),t)
=-1*x(t)-1/2*x(t)3-3*y(t)],
> [x(t),y(t)],t=0..10,[i1,i2,i3,i4],x=-2.5..2.5,
y=-2.5..2.5,
> scene=[x(t),y(t)],scaling=CONSTRAINED,color=GRAY,
linecolor=BLACK,
> thickness=1,stepsize=.05);
> ivals:=seq(-1+.25*i,i=0..8): i1:=seq([x(0)=1,y(0)=i],
i=ivals):
> i2:=seq([x(0)=i,y(0)=1],i=ivals):
> i3:=seq([x(0)=-1,y(0)=i],i=ivals):
508 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
y(t)
2
(a) (b)
1
0
-1
-2
x(t)
2 1 0 -1 -2
y(t)
1
0.5
0
-0.5
-1
x(t)
1
0.5
0
-0.5 -1
Figure 6-37 (a) The origin is a stable node. (b) The origin is a stable spiral
> i4:=seq([x(0)=i,y(0)=-1],i=ivals):
> DEplot([diff(x(t),t)=y(t),diff(y(t),t)
=-10*x(t)-1/2*x(t)3-3*y(t)],
> [x(t),y(t)],t=0..10,[i1,i2,i3,i4],x=-1..1,y=-1..1,
> scene=[x(t),y(t)],scaling=CONSTRAINED,color=GRAY,
linecolor=BLACK,
> thickness=1,stepsize=.01);
EXAMPLE 6.4.6 (Predator Prey): The predatorprey equations take
the form
dx
dt
= ax bxy
dy
dt
= dxy cy
where a, b, c, and d are positive constants. x represents the size of the
prey population at time t while y represents the size of the predator
population at time t. We use solve to calculate the rest points. In this
case, there is one boundary rest point, E
0
= (0, 0), and one interior rest
point, E
1
= (c/d, a/b).
> with(linalg):
> with(DEtools):
> rps:=solve(a*x-b*x*y=0,d*x*y-c*y=0,x,y);
rps :=
x = 0, y = 0
x =
c
d
, y =
a
b
E
0
is unstable because one eigenvalue of J(E
0
) is positive. For the lin-
earized system, E
1
is a center because the eigenvalues of J(E
1
) are
complex conjugates.
> eigenvalues(subs(rps[1],eval(jac)));
a, c
> eigenvalues(subs(rps[2],eval(jac)));
ca,
ca
In fact, E
1
is a center for the nonlinear system as illustrated in
Figure 6-38, where we have used a = 1, b = 2, c = 2, and d = 1.
Notice that there are multiple limit cycles around E
1
= (1/2, 1/2).
> inits:=seq([x(0)=i/20,y(0)=i/20],i=3..10):
> DEplot([diff(x(t),t)=x(t)-2*x(t)*y(t),
> diff(y(t),t)=2*x(t)*y(t)-y(t)],[x(t),y(t)],
t=0..50,[inits],
> x=0..2,y=0..2,scene=[x(t),y(t)],scaling=CONSTRAINED,
color=GRAY,
> linecolor=BLACK,thickness=1,stepsize=.1);
In this model, a stable interior rest state is not possible.
510 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
The complexity of the behavior of solutions to the system increases
based on the assumptions made. Typical assumptions include adding
satiation terms for the predator (y) and/or limiting the growth of the
prey (x). The standard predator prey equations of Kolmogorov type,
x
= x
_
1
1
K
x
_
mxy
a +x
y
= y
_
mx
a +x
s
_
,
(6.40)
incorporate both of these assumptions.
We use solve to nd the three rest points of system (6.40). Let E
0
=
(0, 0) and E
1
= (k, 0) denote the two boundary rest points, and let E
2
represent the interior rest point.
> with(linalg):
> with(DEtools):
> rps:=solve(alpha*x*(1-1/k*x)-m*x*y/(a+x)=0,
y*(m*x/(a+x)-s)=0,x,y);
rps :=
_
x = 0, y = 0
_
,
_
y = 0, x = k
_
,
_
y =
a (mk +ks +sa)
k
_
m
2
2 ms +s
2
_ , x =
sa
m+s
_
The Jacobian, J, is calculated next in s1 with jacobian.
> s1:=jacobian([alpha*x*(1-1/k*x)-m*x*y/(a+x),
y*(m*x/(a+x)-s)],[x,y]);
1 2 x
y
1/10+x
+
xy
(1/10+x)
2
x
1/10+x
y
_
_
1/10 +x
_
1
x
(1/10+x)
2
_
x
1/10+x
s
Because J(E
0
) has a positive eigenvalue, E
0
is unstable.
> e0:=subs(rps[1],eval(s1));
_
1 0
0 s
_
> eigenvalues(e0);
, s
The stability of E
1
is determined by the sign of ms am/(a +k).
> e1:=subs(rps[2],eval(s1));
6.4 Systems of Equations 511
1
10
11
0
10
11
s
> eigs1:=eigenvalues(e1);
eigs1 := ,
mk +ks +sa
a +k
The eigenvalues of J(E
2
) are quite complicated.
> e2:=subs(rps[3],eval(s1)):
> eigenvalues(e2);
1/2
s
2
a +s
2
k s mk + sam+
s
4
2
a
2
+2 s
4
2
ak +2 s
3
2
a
2
m+s
4
2
k
2
2 s
3
2
k
2
m+s
2
2
m
2
k
2
2 s
2
2
m
2
ka +
2
s
2
a
2
m
2
+4 mks
4
a +4 mk
2
s
4
12 m
2
k
2
s
3
8 m
2
ks
3
a +12 m
3
k
2
s
2
+4 m
3
ks
2
a 4 m
4
k
2
s
mks m
2
k
,
1/2
s
2
a +s
2
k s mk + sam
s
4
2
a
2
+2 s
4
2
ak +2 s
3
2
a
2
m+s
4
2
k
2
2 s
3
2
k
2
m+s
2
2
m
2
k
2
2 s
2
2
m
2
ka +
2
s
2
a
2
m
2
+4 mks
4
a +4 mk
2
s
4
12 m
2
k
2
s
3
8 m
2
ks
3
a +12 m
3
k
2
s
2
+4 m
3
ks
2
a 4 m
4
k
2
s
mks m
2
k
Instead of using the eigenvalues to classify E
2
, we compute the char-
acteristic polynomial of J(E
2
), p() = c
2
2
+ c
1
+ c
0
, and examine the
coefcients. Notice that c
2
is always positive.
> cpe2:=charpoly(e2,lambda);
cpe2 :=
s
3
k+s
3
a+s
2
a+s
2
k2s
2
mks
2
ams
2
kmsmk+sm
2
k+sma+
2
km
2
m(m+s)k
> c0:=simplify(subs(lambda=0,eval(cpe2)));
c0 :=
(mk +ks +sa) s
mk
> c1:=simplify(coeff(cpe2,lambda));
c1 :=
s (sa +ks mk +am)
m(m+s) k
> c2:=simplify(coeff(cpe2,lambda2));
c2 := 1
On the other hand, c
0
and ms am/(a+k) have the same sign because
> simplify(c0/eigs1);
512 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
(mk +ks +sa) s
mk
is always positive. In particular, if ms am/(a +k) < 0, E
1
is stable.
Because c
0
is negative, by Descartes rule of signs, it follows that p()
will have one positive root and hence E
2
will be unstable.
On the other hand, if m s am/(a + k) > 0 so that E
1
is unstable,
E
2
may be either stable or unstable. To illustrate these two possibilities
let = K = m = 1 and a = 1/10. We recalculate.
> alpha:=1:k:=1:m:=1:a:=1/10:
> rps:=solve(alpha*x*(1-1/k*x)-m*x*y/(a+x)=0,
y*(m*x/(a+x)-s)=0,x,y);
rps :=
x = 0, y = 0
,
x = 1, y = 0
x = 1/10
s
1 +s
, y =
1
100
10 +11 s
(1 +s)
2
> s1:=jacobian([alpha*x*(1-1/k*x)-m*x*y/(a+x),
y*(m*x/(a+x)-s)],[x,y]);
1 2 x
y
1/10+x
+
xy
(1/10+x)
2
x
1/10+x
y
1/10 +x
x
(1/10+x)
2
x
1/10+x
s
> e2:=subs(rps[3],eval(s1)):
> cpe2:=charpoly(e2,lambda);
cpe2 := 1/10
10
2
10
2
s 9 s +11 s
2
+10 s 21 s
2
+11 s
3
1 +s
> c0:=simplify(subs(lambda=0,cpe2));
c0 := 1/10 s (10 +11 s)
> c1:=simplify(coeff(cpe2,lambda));
c1 := 1/10
s (9 +11 s)
1 +s
> c2:=simplify(coeff(cpe2,lambda2));
c2 := 1
Using solve, we see that
1. c
0
, c
1
, and c
2
are positive if 9/11 < s < 10/11, and
2. c
0
and c
2
are positive and c
1
is negative if 0 < s < 9/11.
6.4 Systems of Equations 513
> solve(c0>0 and c1>0,s);
9
11
< s, s <
10
11
0 < s, s <
9
11
x =
19
30
, y =
121
450
> ivals:=seq(i/14,i=0..14):
> i1:=seq([x(0)=1,y(0)=i],i=ivals):
> i2:=seq([x(0)=i,y(0)=1],i=ivals):
> DEplot([diff(x(t),t)=alpha*x(t)*(1-1/k*x(t))
-m*x(t)*y(t)/(a+x(t)),
> diff(y(t),t)=y(t)*(m*x(t)/(a+x(t))-19/22)],
> [x(t),y(t)],t=0..25,[i1,i2],x=0..1,y=0..1,
scene=[x(t),y(t)],
> scaling=CONSTRAINED,color=GRAY,linecolor=BLACK,
> thickness=1,stepsize=.075);
On the other hand, using s = 8/11 (so that E
2
is unstable) in Figure 6-40
we see that all nontrivial solutions appear to approach a limit cycle.
> DEplot([diff(x(t),t)=alpha*x(t)*(1-1/k*x(t))
-m*x(t)*y(t)/(a+x(t)),
> diff(y(t),t)=y(t)*(m*x(t)/(a+x(t))-8/11)],
> [x(t),y(t)],t=0..50,[i1,i2],x=0..1,y=0..1,
scene=[x(t),y(t)], > scaling=CONSTRAINED,color=GRAY,
linecolor=BLACK,thickness=1,stepsize=.075);
The limit cycle is shown more clearly in Figure 6-41.
> DEplot([diff(x(t),t)=alpha*x(t)*(1-1/k*x(t))
-m*x(t)*y(t)/(a+x(t)),
> diff(y(t),t)=y(t)*(m*x(t)/(a+x(t))-8/11)],
> [x(t),y(t)],t=0..50,[[x(0)=.759,y(0)=.262]],x=0..1,y=0..1,
scene=[x(t),y(t)],
514 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
> scaling=CONSTRAINED,color=GRAY,linecolor=BLACK,
thickness=1,
> arrows=NONE,stepsize=.075);
y(t)
1
0.8
0.6
0.4
0.2
0
x(t)
1 0.8 0.6 0.4 0.2 0
Figure 6-39 s = 19/22
y(t)
1
0.8
0.6
0.4
0.2
0
x(t)
1 0.8 0.6 0.4 0.2 0
Figure 6-40 s = 8/11
6.4 Systems of Equations 515
y(t)
1
0.8
0.6
0.4
0.2
0
x(t)
1 0.8 0.6 0.4 0.2 0
Figure 6-41 A better view of the limit cycle without the direction eld
Also see Example 6.4.4.
EXAMPLE 6.4.7 (Van-der-Pols equation): In Example 6.4.4 we saw
that Van-der-Pols equation x
x
2
1
+ x = 0 is equivalent
to the system
= y
y
1 x
2
y x
.
Classify the equilibrium points, use dsolve with the numeric option,
toapproximate the solutions tothis nonlinear system, andplot the phase
plane.
SOLUTION: We nd the equilibrium points by solving
y = 0
1 x
2
y x = 0
. From the rst equation, we see that y = 0. Then,
substitution of y = 0 into the second equation yields x = 0. There-
fore, the only equilibrium point is (0, 0). The Jacobian matrix for this
system is
J(x, y) =
0 1
1 2xy
x
2
1
.
516 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
The eigenvalues of J(0, 0) are
1,2
=
1
2
_
_
2
4
_
.
> with(DEtools):
> with(linalg):
> f:=(x,y)->y:
> g:=(x,y)->-x-mu*(x2-1)*y:
> jac:=jacobian([f(x,y),g(x,y)],[x,y]);
_
0 1
1 2 xy
_
x
2
1
_
_
> eigenvalues(subs([x=0,y=0],jac));
1/2 x
2
+1/2 +1/2
_
2
x
4
2
2
x
2
+
2
4 8 xy,
1/2 x
2
+1/2 1/2
_
2
x
4
2
2
x
2
+
2
4 8 xy
Alternatively, the sequence of commands
> lin_mat:=array([[0,1],[-1,mu]]):
> with(linalg):
> eigs:=eigenvals(lin_mat);
eigs := 1/2 +1/2
_
2
4, 1/2 1/2
_
2
4
gives us the same result.
Notice that if > 2, then both eigenvalues are positive and real.
Hence, we classify (0, 0) as an unstable node. On the other hand, if
0 < < 2, then the eigenvalues are a complex conjugate pair with a
positive real part. Hence, (0, 0) is an unstable spiral. (We omit the case
= 2 because the eigenvalues are repeated.)
> sys:=mu->[diff(x(t),t)=y(t),diff(y(t),t)
=mu*(1-x(t)2)*y(t)-x(t)];
sys :=
_
d
dt
x (t) = y (t) ,
d
dt
y (t) =
_
1 (x (t))
2
_
y (t) x (t)
_
We now show several curves in the phase plane that begin at various
points for various values of by using seq to generate a list of ordered
pairs that will correspond to the initial conditions in the initial-value
problem.
> inits1:=seq([x(0)=0.1*cos(2*Pi*i/4),
y(0)=0.1*sin(2*Pi/4)],i=0..4);
6.4 Systems of Equations 517
inits1 :=
[x (0) = 0.1, y (0) = 0.1], [x (0) = 0.0, y (0) = 0.1],
[x (0) = 0.1, y (0) = 0.1]
> inits2:=seq([x(0)=-5,y(0)=-5+10*i/9],i=0..9);
inits2 :=
x (0) = 5, y (0) =
35
9
x (0) = 5, y (0) =
35
9
x (0) = 5, y (0) =
25
9
x (0) = 5, y (0) =
25
9
> inits3:=seq([x(0)=5,y(0)=-5+10*i/9],i=0..9):
> inits4:=seq([x(0)=-5+10*i/9,y(0)=-5],i=0..9):
> inits5:=seq([x(0)=-5+10*i/9,y(0)=5],i=0..9):
> initconds:=union(inits1,inits2,inits3,inits4,inits5):
> nops(initconds);
39
We then use phaseportrait in the same way as we use DEplot to
graph various solutions.
> phaseportrait(sys(1/2),[x(t),y(t)],t=0..20,initconds,
x=-5..5,y=-5..5,
> arrows=NONE,linecolor=BLACK,stepsize=0.05);
> phaseportrait(sys(1),[x(t),y(t)],t=0..20,initconds,
x=-5..5,y=-5..5,
> arrows=NONE,linecolor=BLACK,stepsize=0.05);
> phaseportrait(sys(3/2),[x(t),y(t)],t=0..20,initconds,
x=-5..5,y=-5..5,
> arrows=NONE,linecolor=BLACK,stepsize=0.05);
> phaseportrait(sys(3),[x(t),y(t)],t=0..20,initconds,
x=-5..5,y=-5..5,
> arrows=NONE,linecolor=BLACK,stepsize=0.05);
We show all four graphs together in Figure 6-42. In each gure, we
see that all of the curves approach a curve called a limit cycle. Physically,
the fact that the systemhas a limit cycle indicates that for all oscillations,
518 Chapter 6 Applications Related to Ordinary and Partial Differential Equations
y
4
2
0
-2
-4
x
4 2 0 -2 -4
y
4
2
0
-2
-4
x
4 2 0 -2 -4
y
4
2
0
-2
-4
x
4 2 0 -2 -4
y
4
2
0
-2
-4
x
4 2 0 -2 -4
Figure 6-42 Solutions to the Van-der-Pol equation for various values of
the motion eventually becomes periodic, which is represented by a
closed curve in the phase plane.