% script hw13_20
% calculates the critical points of a phase plane system,
% evaluates the Jacobian, and computes the eigenvalues and 
% eigenvectors at each critical point

clear all
% find critical points 
[x,y] = solve('6*x - 5*y +x^2 = 0','2*x-y+y^2 = 0')
% evaluate symbolic expressions to produce numerical values
x0 = eval(x);
y0 = eval(y);
% define symbolic functions for F and G
xp = sym('6*x1 - 5*y1 +x1^2');
yp = sym('2*x1-y1+y1^2');
J = jacobian([xp;yp]);
n = length(x0)
for i = 1:n
    sprintf('------------------------')
    i
% set x1, y1, the symbolic variables used in the Jacobian,
% to one of the critical points
    x1 = x0(i);y1 = y0(i);
    [x1,y1]
% evaluate the components of the Jacobian
    a = eval(J(1,1));
    b = eval(J(1,2));
    c = eval(J(2,1));
    d = eval(J(2,2));
% define the linearization matrix at i-th critical point
% and compute its eigenvectors V and eigenvalues D
    A = [a, b;c, d]
    [V,D]=eig(A)
end

