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

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

Maple 2021

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);
 (1)
 > evalsN:=evalf(%);
 (2)
 (3)
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}