Figure 2.2:

Dynamical behavior on the region boundaries for the planar system dx/dt = Ax, A \in \mathbb {R}^{2 x2}.

Code for Figure 2.2

Text of the GNU GPL.

main.m


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
% the boundary of the  planar dynamics figure()
% jbr, 10/2/2011

% axes and (trace)^2 = 4 det line

x = linspace(-5,5,101)';
y = x.*x/4;
quad = [x, y];
lines = [-5, 0, 0, -7,   0,  0.75; ...
          5, 0, 0,  0,   0,   10];

% neutral center
theta = linspace(0, 2*pi, 101)';
xcenter = [cos(theta), sin(theta), 0.5*cos(theta), 0.5*sin(theta)];


s = "neutral center";
% outer circle
% nrow = 11; skip = 4;
% inner circle
nrow = 7; skip = 11;
%setarrow(s, nrow, skip, xcenter)

% stable node
x0 = [1;1];
nts = 101;
time = linspace(0,15,nts)';
A = [-1, -2; 0, -1];
x = zeros(2,nts);
for  i = 1:length(time);
  x(:,i) = expm(A*time(i))*x0;
end
x1 = x';
x0 = [-1; 1];
x = zeros(2,nts);
for  i = 1:length(time);
  x(:,i) = expm(A*time(i))*x0;
end
x2 = x';
x0 = [-1; -1];
x = zeros(2,nts);
for  i = 1:length(time);
  x(:,i) = expm(A*time(i))*x0;
end
x3 = x';
x0 = [1; -1];
x = zeros(2,nts);
for  i = 1:length(time);
  x(:,i) = expm(A*time(i))*x0;
end
x4 = x';
xnode = [x1, x2, x3, x4];
% 1st and 3rd quadrant arrows
% nrow = 3; skip= 2
% 2nd and 4th quadrant arrows
nrow = 8; skip = 5;
s = "stable node";
%setarrow(s, nrow, skip, xnode);

%unstable node; reverse time (i.e., arrows)
% 1st and 3rd quadrant arrows
nrow = 4; skip = -2;
% 2nd and 4th quadrant arrows
% nrow = 13; skip = -5;
s = "unstable node";
%setarrow(s, nrow, skip, xnode);

% stable star
xstar = zeros(2,8);
xstar(1,:) = [1, 1, -1, 1, -1, -1, 1, -1];

% unstable star; reverse arrows

save "phasebound.dat" quad lines xcenter xnode xstar

setarrow.m


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
function retval = setarrow(s, nrow, skip, x)
% print out gnuplot arrow commands
narrows = columns(x)/2;
printf ("gnuplot arrow command -- %s\n", s)
for i = 1:narrows
  cols = 2*i-1:2*i;
  arrowloc = [x(nrow,cols)'; x(nrow+skip,cols)'];
  printf ("set arrow %i from %g, %g to %g, %g filled size graph 0.03, 15 lw 0\n", ...
           i, arrowloc)
end