%
%  codeHW8a.m -- 11 nov 02 -- djm
%
%  - root tracing plot

alpha = -12:0.2:8;

%  coeffs of char poly

b = (4-alpha);  c = (10-4*alpha);

%  eigenvalues

r1 = 0.5*( -b + sqrt(b.^2 - 4*c) );
r2 = 0.5*( -b - sqrt(b.^2 - 4*c) );

%  plot on complex plane

figure(1);  clf;  hold on
plot(real(r1),imag(r1),'bo')
plot(real(r2),imag(r2),'rx')

plot(-4+sqrt(10),0,'k*')
text(-7.8,0.3,'alpha = -4-2sqrt(10)')
plot(-4-sqrt(10),0,'k*')
text(-5.8,-0.3,'alpha = -4+2sqrt(10)')
plot(0,0,'k*')
text(0.2,0.3,'alpha = 5/2')

title('\bf complex eigenvalues for various -12<\alpha<8 (blue = plus root, red = minus root)')
xlabel('\bf real-axis')
ylabel('\bf imag-axis')

%  direction fields

figure(2);  clf;  hold on

subplot(2,2,1);  hold on
alpha = -4-2*sqrt(10) - 1
A = [alpha 10 ; -1 -4];  codeHW8b

subplot(2,2,2);  hold on
alpha = -4
A = [alpha 10 ; -1 -4];  codeHW8b

subplot(2,2,3);  hold on
alpha = -4+2*sqrt(10) + 0.001
alpha = 2.4
A = [alpha 10 ; -1 -4];  codeHW8b

subplot(2,2,4);  hold on
alpha = 5
A = [alpha 10 ; -1 -4];  codeHW8b
