0

I am attempting to find the value of K such that the following matrix has any eigenvalue with a positive real part, but I keep getting nonsense. What's a better way of doing this?

K = 0;
A = [  0 1 0; 0 0 1; -K -2 -3];

while K < 10
    e = eig(A);
    A = [  0 1 0; 0 0 1; -K -2 -3 ];
        if any(real(e)) > 0
            K
            break;
        end
    K = K + 1/100;    
end
garserdt216
  • 163
  • 6
  • 2
    Unless you're trying to implement a search algorithm (which the code you gave is mostly not), I'd say you need to calculate out the characteristic polynomial and deduce a value (or range) of `K` from the [cubic's discriminant](https://en.wikipedia.org/wiki/Cubic_function#The_nature_of_the_roots) – TroyHaskin Mar 28 '16 at 03:33

1 Answers1

0

Elaborating on the comment of @TroyHaskin, here is a solution using the characteristic polynomial of your above question.

Note that the characteristic polynomial from above is given by

-x^3 - 3x^2 - 2x - K

solved here. Playing around with the above equation and roots in matlab, it is easy enough to find a solution that satisfies your constraint

>> roots([-1, -3, -2, 0])

ans =

     0
    -2
    -1

>> roots([-1, -3, -2, 1])

ans =

  -1.6624 + 0.5623i
  -1.6624 - 0.5623i
   0.3247 + 0.0000i

Which shows that for K=1 you have an eigenvalue with a strictly positive real part.

mgilbert
  • 3,495
  • 4
  • 22
  • 39