kill(all)$
load(eigen)$

appendix:complex eigenvalues,'revision1'
peter.vlasschaert@gmail.com,27/03/2017

see: 
Lecture 26: Continuation: Repeated Real Eigenvalues

depends(x,t);

simple example:

p[1]:'diff(x[1],t)=x[1]+2*x[2];
p[2]:'diff(x[2],t)=-x[1]-x[2];

M1:zeromatrix(2,2)$
for i:1 thru 2 do
  for j:1 thru 2 do
M1[i,j]:coeff(part(p[i],2),x[j]);

coef.Marix : 'p[i] , i=1..3'

M1;

eigenvalues ,M2       '|A-lambda*I|=0'
I=matrix(M3)

M2:zeromatrix(2,2)$
M3:zeromatrix(2,2)$
for i:1 thru 2 do
  M3[i,i]:1;
for i:1 thru 2 do
  for j:1 thru 2 do
  M2[i,j]:M1[i,j]-lambda*M3[i,j];

M2;

find :eigenvalues 'lambda'

p1:ratsimp(determinant(M2))=0;

p2:allroots(p1);
p21:p2[1];
p22:p2[2];
p210:part(p21,2);
p220:part(p22,2);

p3:[vals,vecs]:eigenvectors(M1);

p4:vals[1];
p5:vecs;

p6:p5[1][1];
p7:p5[2][1];

solution 'system diff.equations':p[i],i=1,2,3
math: e^(i*t) = cos(t)+i*sin(t)

p8:x[1]=c1*p7[1]*%e^(p210*t)+c2*p6[1]*%e^(p220*t);
p9:x[2]=c1*p7[2]*%e^(p210*t)+c2*p6[2]*%e^(p220*t);;

 'x '(t)
    1       1

realpart 'x '
           1

p10:realpart(part(p8,2));

p101:X=ratsimp(p10);
p101:ev(p101,c1+c2=c);

imaginairpart 'x '
                1

p11:imagpart(part(p8,2));

 'x '(t)
   2

realpart 'x '
           2

p12:realpart(part(p9,2));

p121:Y=ratsimp(p12);
p122:ev(p121,c1+c2=c);

imaginairpart 'x '
                2

p13:imagpart(part(p9,2));

p14:ev(p101,c=k);
p15:ratsimp(ev(p122,c=k));

x(t),y(t) gives ellips ' x,y system '

delete : to see other ellipse

for k:0 step 0.5 thru 2 do
plot2d([['parametric, part(p14,2), part(p15,2), [t, -6, 6], [nticks, 300]]],
    [x,-5,5],[plot_format, gnuplot])$

statement : imaginair numbers = realpart+%i*imagpart

< parametricplot2d > =>

rem:plot2d([['parametric, 2*cos(t), -sin(t)-cos(t), [t, -6, 6], [nticks, 300]]],
     [x,-5,5],[plot_format, gnuplot])$
 