# Is there any matlab code to find out maximum eigenvalue of the randomly generated matrices?

I am running a matlab code for computing the Drazin inverse of the matrix $A$.

Initial value of the iteration method is $X_0 = \beta A^{k}$, where $k = index (A)$(For $A\in \mathbb{C}^{n\times n}$, the smallest nonnegative integer $k$ such that $rank(A^{k+1}) = rank(A^k)$ is called the index of $A$). .

Parameter $\beta$ satisfies: $0<\beta < \frac{2}{\lambda_{max}(A^{k+1})}$.

I want to test the method for the randomly generated matrices so I need a matlab code to determine the maximum eigen value of the matrix $A^k$ so that I may easily choose the value of $\beta$.

Could anybody help me with this. Thanks

-
You may use $\mathtt{eig}(\cdot)$ and then call $\mathtt{max}(\cdot)$? – Lord Soth Apr 24 '13 at 18:54
Depending on your size of matrix, using eigs to find only the largest eigenvalue with power-method may be faster. – Memming Apr 24 '13 at 18:57
@Memming I am using $1000 \times 1000$ matrix. – srijan Apr 24 '13 at 18:59

Are you looking for the largest eigenvalue or the eigenvalue with the largest magnitude? For magnitude,

a=rand(1000);
max(abs(eig(a)))


is much slower especially if you want to repeat it multiple times because it will compute all of the eigenvalues and then pick the max. You might want to use

a=rand(1000);
eigs(a,1)


which will compute and return only the largest magnitude eigenvalue.

-
Thank you very much. It helped me. :) – srijan Apr 24 '13 at 21:52