Can I generate a random matrix with a given condition number using the infinite norm

condition numbermatricesmatrix-norms

I'm trying to generate random matrices that have a given condition number for inversion.
For that I need to have matrices for which the condition number is low (or controlled) when computed using the infinite norm.
I've found some methods used the SVD method to generate matrices with specific condition numbers using the 2-norm, but I have yet to find a method that generates matrices with controlled infinite norm based condition number.
Thanks!

Best Answer

Choose any matrix $E \in \mathbb{R}^{m \times m}$ and scale the rows such that $\|E\|_\infty = \epsilon < 1$. Consider the matrix $$A=I-E.$$ where $I$ is the identity matrix of dimension $m$. Then $A$ is nonsingular and $$A^{-1} = \sum_{j=0}^\infty E^j.$$ This is known as the Neumann series. By the triangular inequality we have $$\|A\|_\infty \leq 1 + \|E\|_\infty$$ and $$\|A^{-1}\|_\infty \leq \sum_{j=0}^\infty \|E\|_\infty^j = \frac{1}{1 - \|E\|_\infty}.$$ It follows that $$\kappa_\infty(A) = \|A\|_\infty \|A^{-1}\|_\infty \leq \frac{1 + \epsilon}{1 - \epsilon}.$$

A complete MATLAB program that implements this strategy is given here.

function A=TestMatrix(m,epsilon)

% Generates a nonsingular matrix while bounding the condition number
%
% Call sequence: A = TestMatrix(m,epsilon)
%
% INPUT:
%    m        the dimension of the matrix
%    epsilon  a real number in (0,1)
%
% OUTPUT:
%    A        an m by m nonsingular matrix
%
% The infinity norm condition number of A is bounded by 
% 
%                (1+epsilon)/(1-epsilon)
% 

% Programming by Carl Christian Kjelgaard Mikkelsen
%   2021-10-22 Initial programming and testing

% Generate a random matrix with entries uniformly distributed in (0,1)
E=rand(m,m);
% Compute the sum of the absolute values of E along each row
w=abs(E)*ones(m,1);
% Scale E to ensure that the infinity norm is epsilon
E=epsilon*(diag(w)\E);
% Construct the final matrix
A=eye(m,m)-E;