Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Finding eigenvalue - MatLab

  1. Oct 30, 2011 #1
    I'm tinkering with a code snippet where a part finds eigenvalues.
    Code (Text):
    The thing is, I tried to do it not using eig() to grasp this and got stuck. Could anyone shed some light on this..? How do I find the smallest eigenvalue?
  2. jcsd
  3. Oct 30, 2011 #2
    Hmm... I might be a little bit closer. This seems to compute the biggest eigenvalue.
    Code (Text):
        while (abs(lambda - lambda_old) > tol)
            lambda_old = lambda;
            lambda = y'*A*z/norm(z, 2);   %this part should be altered to compute the smallest.
  4. Oct 30, 2011 #3


    User Avatar
    Gold Member

    d = eig(A) returns a vector of the eigenvalues of matrix A (notice, I'm assigning it to 'd')

    to find the smallest value in a vector:

    smallest = min(d)

    so, all you really have is:

    Code (Text):
    d = eig(A)
    sm = min(d)
    where sm is the smallest eigenvalue.
    Not quite what matlab calls the smallest when mixing complex numbers with real numbers.
  5. Oct 30, 2011 #4


    User Avatar
    Gold Member

    ok, weird... so:

    according to min, the first entry in A is the "smallest"
    Code (Text):
    A =

      1.000000000000000 + 1.000000000000000i
     -1.000000000000000 + 1.000000000000000i

    >> min(A)

    ans =

      1.000000000000000 + 1.000000000000000i
    but according to the lessthan sign, the second entry is the "smallest"

    Code (Text):
     >> if A(1) < A(2)
    >>if A(2) < A(1)
  6. Oct 30, 2011 #5
    I'm trying to set up a power iteration - not using eig(). I'm pretty sure I get the power iteration right, but the inverted power iteration to get the smallest..?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook