Question: How to quickly find the spectral radius of a matrix (just need numerical results)

The spectral radius  is maximum of the absolute values of the eigenvalues of the matrix A.  We can use the function SpectralRadius in Student package. But we noticed a sentence in the help document:

The output from this procedure will be as symbolic as computationally feasible. If the exact spectral radius of A is too time-consuming to compute, it may be computed numerically.

This means that SpectralRadius will evaluate the exact value when it can. Anyway, the internal evaluation process will take time. So for the sake of efficiency, we just want the numerical results of the spectral radius of a matrix. 


I tried to write the following function, but I feel that it is not very efficient, especially for solving characteristic polynomials and their roots.  I even feel that there is a way to find the spectral radius without taking the absolute value of all the eigenvalues and ordering them. 

Spectralradius := proc(A::Matrix)
 local Spectrum;
 Spectrum := sort(abs~([fsolve(LinearAlgebra:-
 CharacteristicPolynomial(A,x)=0,x )]),`>`);
 Spectrum[1]
end proc:

 

One example: In general, the matrices I encounter come from adjacency matrices of graphs, which are always real symmetric. So their eigenvalues are always real. But the Eigenvalues command very slow because it's always trying to get the exact value. So If we use Eigenvalues  to find all the eigenvalues and then sort them, it will be very slow.  Thus  I'm thinking about finding the numerical results.


 

with(LinearAlgebra):
with(GraphTheory):
G2:=Graph({{1,2},{2,3},{3,1},{3,4}}):
A2:=AdjacencyMatrix(G2):
Eigenvalues(A2);

Vector(4, {(1) = -1, (2) = (1/3)*(1+(3*I)*sqrt(111))^(1/3)+(10/3)/(1+(3*I)*sqrt(111))^(1/3)+1/3, (3) = -(1/6)*(1+(3*I)*sqrt(111))^(1/3)-(5/3)/(1+(3*I)*sqrt(111))^(1/3)+1/3+((1/2)*I)*sqrt(3)*((1/3)*(1+(3*I)*sqrt(111))^(1/3)-(10/3)/(1+(3*I)*sqrt(111))^(1/3)), (4) = -(1/6)*(1+(3*I)*sqrt(111))^(1/3)-(5/3)/(1+(3*I)*sqrt(111))^(1/3)+1/3-((1/2)*I)*sqrt(3)*((1/3)*(1+(3*I)*sqrt(111))^(1/3)-(10/3)/(1+(3*I)*sqrt(111))^(1/3))})

(1)

evalsN:=evalf(%);

Vector(4, {(1) = -1., (2) = 2.170086486-0.4000000000e-9*I, (3) = -1.481194304-0.5062177830e-9*I, (4) = .3111078169+0.7062177830e-9*I})

(2)

``

(3)

with(Student):
SpectralRadius(A2)

2.170086487

(4)

 

Maybe I need a way to find all the numerical eigenvalues of a real symmetric matrix not using  CharacteristicPolynomial or Eigenvalues.

Download zlc_1.mw

Please Wait...