product of two well-conditioned matrices become ill-conditioned

275 Views Asked by At

All I want to do is to construct a matrix $\mathcal{A}$ (refer to bigA2 and bigA3 in the code) whose $i$-th row is $vec(U_1^TA_iU_1)^T$, and $U_1$ is a column-orthogonal matrix with columns being those $r$ eigenvectors corresponding to the $r$ positive eigenvalues of $X_0$. In the code, bigA1=$\mathcal{A_1}$ is the matrix whose $i$-th row is $vec(A_i)^T$. Using facts from Kronecker product, we can also construct the matrix I want by the formula:

$\mathcal{A}=\mathcal{A_1}(U_1^T\otimes U_1^T)^T$

However, the output is

>> [U1_cond,A_cond1,A_cond2,A_cond3]=test(X0,A)

U1_cond =

    1.0000


A_cond1 =

    5.4172


A_cond2 =

   Inf


A_cond3 =

   Inf

That means even if the condition numbers $\kappa(U_1^T\otimes U_1^T)=1$ and $\kappa(\mathcal{A_1})=5.4172$, $\kappa(\mathcal{A})=+\infty$, no matter which method I used to obtain it. This contradicts to the fact that condition number is sub-multiplicative.

Can anyone please explain this to me? Whether it's the problem of the code or some other maths problem? Thanks in advance for any possible answer.

The code I used to implement my idea:

function [U1_cond,A_cond1,A_cond2,A_cond3]=test(X0,A)
bigA1=[];
for i=1:size(A,1)
    bigA1=[bigA1;A{i}(:)'];
end
A_cond1=cond(bigA1);
[U, D]=eig(X0);
r=sum(diag(D)>10^(-12));
[D, order]=sort(diag(D),'descend');
U=U(:,order);
U1=U(:,1:r);
U1_cond=cond(kron(U1',U1'));
bigA2=(kron(U1',U1')*bigA1')';
A_cond2=cond(bigA2);
if (r<size(U,2))
   U2=U(:,r+1:size(U,2)); 
else U2=[];
end
D=diag(D);
X0=D(1:r,1:r);
for i=1:size(A,1)
   A{i}=U1'*A{i}*U1;
end
bigA3=[];
for i=1:size(A,1)
    bigA3=[bigA3;A{i}(:)'];
end
A_cond3=cond(bigA3);

where the inputs A is a cell $\{A_i\}$ of matrices and $X_0$ is a matrix.

If you need the input data, please let me know.