简体   繁体   中英

Multiplication of matrices involving inverse operation: getting infinity

In my earlier question asked here : Matlab: How to compute the inverse of a matrix

I wanted to know how to perform inverse operation

A = [1/2, (1j/2), 0;
     1/2, (-1j/2), 0;
     0,0,1]

 T = A.*1

 Tinv = inv(T)

The output is Tinv =

   1.0000             1.0000                  0          
        0 - 1.0000i        0 + 1.0000i        0          
        0                  0             1.0000 

which is the same as in the second picture. The first picture is the matrix A

Ť

T逆

However for a larger matrix say 5 by 5, if I don't use the identity, I to perform element wise multiplication, I am getting infinity value. Here is an example

A = [1/2, (1j/2),  1/2, (1j/2),  0;
     1/2, (-1j/2), 1/2, (-1j/2), 0;
     1/2, (1j/2),  1/2, (1j/2),  0;
     1/2, (-1j/2), 1/2, (-1j/2), 0;
     0,    0 ,     0 ,  0,      1.00
          ];

T = A.*1

Tinv = inv(T)
Tinv =

   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf

So, I tried to multiply T = A.*I where I = eye(5) then took the inverse Eventhough, I don't get infinity value, I am getting element 2 which is not there in the picture for 3 by 3 matrix case. Here is the result

Tinv =

   2.0000                  0                  0                  0                  0          
        0                  0 + 2.0000i        0                  0                  0          
        0                  0             2.0000                  0                  0          
        0                  0                  0                  0 + 2.0000i        0          
        0                  0                  0                  0             1.0000    

If for 3 by 3 matrix case, I use I = eye(3) , then again I get element 2.

Tinv =

   2.0000                  0                  0          
        0                  0 + 2.0000i        0          
        0                  0             1.0000 

What is the proper method?

Question : For general case, for any sized matrix m by m , should I multiply using I = eye(m) ? Using I prevents infinity values, but results in new numbers 2 . I am really confused. Please help

UPDATE: Here is the full image where Theta is a vector of 3 unknowns which are Theta1, Theta1* and Theta2 are 3 scalar valued parameters. Theta1 is a complex valued number, so we are representing it into two parts, Theta1 and Theta1* and Theta2 is a real valued number. g is a complex valued function. The expression of the derivative of a complex valued function with respect to Theta evaluates to T^H. Since, there are 3 unknowns, the matrix T should be of size 3 by 3.

图片新

your problem is slightly different than you think. The symbols ( I , 0 ) in the matrices in the images are not necessarily scalars (only for n = 1 ), but they are actually square matrices .

I is an identity matrix and 0 is a matrix of zeros. if you treat these matrix like that you will get the expected answers:

n = 2; % size of the sub-matrices
I = eye(n); % identity matrix
Z = zeros(n); % matrix of zeros
% your T matrix
T = [1/2*I, (1j/2)*I, Z;
    1/2*I, (-1j/2)*I, Z;
    Z,Z,I];
% inverse of T
Tinv1 = inv(T);
% expected result
Tinv2 = [I,I,Z;
    -1j*I,1j*I,Z;
    Z,Z,I];
% max difference between computed and expected
maxDist = max(abs(Tinv1(:) - Tinv2(:)))

First you should know , whether you should do

T = A.*eye(...)

or

I = A.*1 %// which actually does nothing

These are completely different things. Be sure what you need, then think about the code.


The reason why you get all inf is because the determinant det of your matrix is zero .

det(T) == 0

So from the mathematical point of view your result is correct, as building the inverse requires every element of T to be divided by det(T) . Your matrix cannot be inversed. If it should be possible, the error is in your input matrix, or again in your understanding of the actual underlying problem to solve.

Edit

After your question update, it feels like you're actually looking for ctranpose instead of inv .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM