# How to generate square matrices based on constraints on their spectral radii?

After reading the Wikipedia, I am wondering whether there is an algorithm that, given a size $$N$$, can generate an $$N\!\times\! N$$ matrix $$\boldsymbol{W}$$ whose spectral radius satisfies $$\rho(\boldsymbol{W})<1$$, where

$$\rho(\boldsymbol{W}) = \max\limits_{\boldsymbol{W}} \left\{ |\lambda_{1}|, \dots, |\lambda_{n}| \right\}$$

for some natural $$n$$.

• Generate a random matrix $W$ first. Then calculate $\|W\|$ for any submultiplicative norm, such as $\|W\|_\infty=\max_i\sum_j|w_{ij}|$. Now multiply $W$ by $c/\|W\|$, where $c$ is a random number that lies inside $[0,1)$. For this new $W$ we have $\|W\|=c<1$. Hence $\rho(W)<1$. Commented Dec 7, 2022 at 21:23

1. Randomly generate a matrix $$W_0$$ (without a constraint on its spectral radius)
2. Compute $$r_0 = \rho(W_0)$$
3. Generate a random value $$r$$ with $$0 \leq r < 1$$
4. Obtain the desired matrix with $$W = \frac{r}{r_0}W_0$$. We have $$\rho(W) = r < 1$$.
We can make this process faster if we merely require that $$r_0 \geq W_0$$, which means that that the resulting $$W$$ has spectral radius $$\rho(W) \leq r$$. Towards that end, we can simply take $$r_0 = \|W\|$$ for any submultiplicative norm $$\|\cdot\|$$. Note, however, that this makes it relatively unlikely that $$\rho(W)$$ will be close to $$1$$.