inverse of complex matrix

12 views (last 30 days)
Ben Marinberg
Ben Marinberg on 27 Aug 2020
Commented: Stephen23 on 31 Aug 2020
I'm trying to invert a complex matrix using inv() function.
turns out A*inv(A)I and inv(A)*AI .
Of course I'm aware of precision errors, but here I got elements greater than 100 off the main diagonal.
Is there any reason for that?
  1 Comment
Stephen23
Stephen23 on 27 Aug 2020
"Is there any reason for that?"
Matrix inversion is inhernently numeric unstable. It is also seldom required:

Sign in to comment.

Accepted Answer

Bruno Luong
Bruno Luong on 27 Aug 2020
Edited: Bruno Luong on 27 Aug 2020
Yes if you have badly conditioned (or badly scaled), or practically singular matrix. Usualy you get a warning message when computing the inverse.
This happens with real matrix as well, such as
>> M=magic(6)
M =
35 1 6 26 19 24
3 32 7 21 23 25
31 9 2 22 27 20
8 28 33 17 10 15
30 5 34 12 14 16
4 36 29 13 18 11
>> iM=inv(M)
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 8.001607e-19.
iM =
1.0e+15 *
2.251799813685250 -0.000000000000000 -2.251799813685250 -2.251799813685250 -0.000000000000000 2.251799813685250
2.251799813685250 -0.000000000000000 -2.251799813685250 -2.251799813685250 -0.000000000000000 2.251799813685250
-1.125899906842625 0.000000000000000 1.125899906842625 1.125899906842625 0.000000000000000 -1.125899906842625
-2.251799813685250 0.000000000000000 2.251799813685250 2.251799813685250 0.000000000000000 -2.251799813685250
-2.251799813685250 0.000000000000000 2.251799813685250 2.251799813685250 0.000000000000000 -2.251799813685250
1.125899906842624 0 -1.125899906842624 -1.125899906842624 0 1.125899906842624
>> M*iM
ans =
-8.000000000000000 0 8.000000000000000 8.000000000000000 -1.125000000000000 0
0 1.000000000000000 0 0 -0.962843041164940 0.500000000000000
8.000000000000000 -0.000000000000001 -8.000000000000000 -8.000000000000000 -1.773627835340241 8.000000000000000
8.000000000000000 0 -8.000000000000000 -8.000000000000000 0.249352422290674 12.000000000000000
4.000000000000000 0.000000000000000 -4.000000000000000 -4.000000000000000 0.411509381125735 12.000000000000000
8.000000000000000 0 -8.000000000000000 -8.000000000000000 -0.399275413049567 20.000000000000000
>> iM*M
ans =
0 16 9 -2 4 -2
0 20 9 -2 4 0
4 -2 -2 -1 2 1
2 8 6 0 8 6
0 -4 -9 -2 0 0
0 0 0 0 0 0
>> cond(M)
ans =
4.700154791029550e+16
>>
  2 Comments
Ben Marinberg
Ben Marinberg on 31 Aug 2020
My matrix didn't had that high of a condition number, also it didn't gave any warning..
Stephen23
Stephen23 on 31 Aug 2020
@Ben Marinberg : please save your matrix in a .mat file and upload it by clicking the paperclip button.

Sign in to comment.

More Answers (0)

Categories

Find more on Linear Algebra in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!