restart;
with(LinearAlgebra): with(DEtools): with(plots):
buildsys := proc(mat)
{diff(x(t),t)=mat[1,1]*x(t)+mat[1,2]*y(t), diff(y(t),t)=mat[2,1]*x(t)+mat[2,2]*y(t)};
end;
circlepts := proc(numints)
dt := 2*Pi/numints; plist :=[];
for i from 1 to numints do t := (i-1)*dt; plist:=[op(plist), <cos(t),sin(t)>]; od;
return Matrix(plist);
end:
cpts := circlepts(12);
mkinitials := proc(ptmat)
[seq([0, ptmat[1,i], ptmat[2,i]], i=1..ColumnDimension(ptmat))];
end;
mkinitials(cpts);
P := <<1,-2>|<1,1>>;
dmat := DiagonalMatrix([-1/5, -2/5]);
eqns := buildsys(dmat);
DEplot(buildsys(dmat), [x(t), y(t)], t=0..10, mkinitials(cpts), animatecurves=true, color=magnitude, linecolor=blue);
A := P.dmat.P^(-1);
pcpts := P.cpts
DEplot(buildsys(A), [x(t), y(t)], t=0..10, mkinitials(pcpts), animatecurves=true, color=magnitude, linecolor=blue);
dmat := DiagonalMatrix([0.1,0.15]);
DEplot(buildsys(dmat), [x(t), y(t)], t=0..15, mkinitials(cpts), animatecurves=true, color=magnitude, linecolor=blue);
A := P.dmat.P^(-1);
pcpts := P.cpts;
DEplot(buildsys(A), [x(t), y(t)], t=0..15, mkinitials(pcpts), animatecurves=true, color=magnitude, linecolor=blue);
pf := DEplot(buildsys(A), [x(t), y(t)], t=0..15, mkinitials(pcpts), color=magnitude, linecolor=blue):
p1 := plot([P[1,1]*t, P[2,1]*t, t=-7..7], color=green):
p2 := plot([P[1,2]*t, P[2,2]*t, t=-7..7], color=red):
display([pf,p1,p2]);
dmat := DiagonalMatrix([-0.1,0.04]);
DEplot(buildsys(dmat), [x(t), y(t)], t=0..15, mkinitials(circlepts(16)), x=-2..2, y=-2..2, animatecurves=true, color=magnitude, linecolor=blue);
A := P.dmat.P^(-1);
ppts := P.circlepts(16);
DEplot(buildsys(A), [x(t), y(t)], t=0..15, mkinitials(ppts), x=-2..2, y=-2..2, animatecurves=true, color=magnitude, linecolor=blue);
alpha :=1 ; beta := 2; lambda := alpha + beta*I;
Q := copy(P);
M := <<alpha|-beta>, <beta|alpha>>;
A := Q.M.Q^(-1);
Eigenvectors(A);
(u,v):=Column(Q, 1..-1);
P:= < u-I*v|u+I*v>;
P^(-1).A.P;
alpha := 0.1; beta := 2;
M := Matrix([
[alpha, -beta],
[beta, alpha]]);
DEplot(buildsys(M), [x(t),y(t)], t=0..5, [[0, 1, 0]], animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
A := Q.M.Q^(-1);
apt := A.<1,0>;
DEplot(buildsys(A), [x(t),y(t)], t=0..5, [[0,apt[1], apt[2]]], animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
alpha := -0.1; beta := 2;
M := Matrix([
[alpha, -beta],
[beta, alpha]]);
DEplot(buildsys(M), [x(t),y(t)], t=0..7, [[0, 1, 0]], animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
A := Q.M.Q^(-1);
apt := A.<1,0>;
DEplot(buildsys(A), [x(t),y(t)], t=0..7, [[0,apt[1], apt[2]]], animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
alpha := 0; beta := 2;
M := Matrix([
[alpha, -beta],
[beta, alpha]]);
DEplot(buildsys(M), [x(t),y(t)], t=0..4, x=-1.1..1.1, y=-1.1..1.1, [[0, 1, 0]], animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
A := Q.M.Q^(-1);
apt := A.<1,0>;
DEplot(buildsys(A), [x(t),y(t)], t=0..7, [[0,apt[1], apt[2]]],x=-4..4, y=-4..4, animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
lambda := -0.1;
M := Matrix([
[lambda, 1],
[0, lambda]]);
DEplot(buildsys(M), [x(t), y(t)], t=0..30, mkinitials(cpts), animatecurves=true, color=magnitude, linecolor=blue);
sol := dsolve(buildsys(M), [x(t),y(t)]);
subs(sol, y(t)/x(t));
limit(%, t=infinity);
P := copy(Q);
A := P.M.P^(-1);
apts := P.cpts;
DEplot(buildsys(A), [x(t), y(t)], t=0..30, mkinitials(apts), animatecurves=true, color=magnitude, linecolor=blue);
lambda := 0.2;
M := Matrix([
[lambda, 1],
[0, lambda]]);
ippts := Matrix([seq(<i*0.1,-i*0.1/10>, i=-10..10)]);
DEplot(buildsys(M), [x(t), y(t)], t=0..10, mkinitials(ippts), animatecurves=true, color=magnitude, linecolor=blue);
A := P.M.P^(-1);
apts := P.ippts;
DEplot(buildsys(A), [x(t), y(t)], t=0..10, mkinitials(apts), animatecurves=true, color=magnitude, linecolor=blue);
lambda := 0;
M := Matrix([
[lambda, 1],
[0, lambda]]);
ippts := Matrix([seq(<i*0.1,-i*0.1/10>, i=-10..10)]);
DEplot(buildsys(M), [x(t), y(t)], t=0..10, mkinitials(ippts), animatecurves=true, color=magnitude, linecolor=blue);
dsolve(buildsys(M), [x(t),y(t)]);
A := P.M.P^(-1);
apts := P.ippts;