# Symbolic spectra radius of matrix?

**URL:** <https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058>\
**Category:** General Usage\
**Created:** [November 12, 2020, 4:14pm UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058 "2020-11-12T16:14:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [November 12, 2020, 4:14pm UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058/1 "2020-11-12T16:14:49Z")

</div>

I’m looking for the spectral radius of matrix M given by:

M =\left(\begin{array}{ccc}0 & k & r\\1 & 0 & 0\\0 & 1-n & 0\end{array}\right)

where all of k,r,n are non-negative reals.

WolframAlpha can compute the eigenvalues: there are one real and two complex conjugate eigenvalues. But the expressions are really ugly.

Does any of the Julia symbolic packages support spectral radius computations?

---

<div class="post-metadata">

**Author:** ![j\_verzani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_verzani/32/8551_2.png) [@j\_verzani](https://discourse.julialang.org/u/j_verzani)\
**Post date:** [November 12, 2020, 4:51pm UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058/2 "2020-11-12T16:51:17Z")

</div>

SymPy can handle this 3x3 case:

```julia
using SymPy, LinearAlgebra
@vars k r n positive=true
M = [0 k r; 1 0 0; 0 1-n 0]
eigvals(M)

```

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [November 12, 2020, 5:07pm UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058/3 "2020-11-12T17:07:37Z")

</div>

Can I also specify that 0 \< n \< 1?

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [November 12, 2020, 6:07pm UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058/4 "2020-11-12T18:07:29Z")

</div>

You’re solving a cubic polynomial, so the analytical expressions are always going to be ugly, no?

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [November 12, 2020, 8:18pm UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058/5 "2020-11-12T20:18:13Z")

</div>

I _suspect_ the expressions will be ugly (as you say). The problem is that I try to recreate an expression in a publication, and the expression in the publication is really, really simple.

Of course, there is always the possibility that the expression in the publication is incorrect…

---

<div class="post-metadata">

**Author:** ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Post date:** [November 12, 2020, 8:47pm UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058/6 "2020-11-12T20:47:56Z")

</div>

You shoud be able to verify the solution in the paper directly (or show that it’s wrong), by substituting it into \det(A-\lambda I)=0.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [November 12, 2020, 9:25pm UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058/7 "2020-11-12T21:25:03Z")

</div>

Good point.

On second thought… [corrected after tip from `dpsanders`]

\rho(A) =\max\_i |\lambda\_i (A)|

so I guess there is no guarantee that the spectral radius is an eigenvalue?

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [November 13, 2020, 1:32am UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058/8 "2020-11-13T01:32:12Z")

</div>

That should be `max`, not `argmax`. But yes, it’s the modulus of an eigenvalue.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [November 13, 2020, 8:05am UTC](https://discourse.julialang.org/t/symbolic-spectra-radius-of-matrix/50058/9 "2020-11-13T08:05:02Z")

</div>

Yes, of course… the `arg max` would give the i…
