tags:

views:

71

answers:

2

MATLAB calculate INV wrong sometimes:

See this example

[ 8617412867597445*2^(-25), 5859840749966268*2^(-28)]
[ 5859840749966268*2^(-28), 7969383419954132*2^(-32)]

If you put this in MATLAB it doesn't have inverse but in s calculator it has one.

What is going on?

+7  A: 

Please read What every scientist should know about floating point arithmetic

Next, don't compute the inverse anyway. An inverse matrix is almost never necessary, except in textbooks, where it is convenient to write. Sadly, many authors do not appreciate this fact anyway, because they had learned from textbooks by other people who also failed to understand that an inverse matrix is a bad thing to do in general.

Since this matrix is numerically singular in double precision arithmetic, the inverse of that matrix is meaningless.

Use of the matlab backslash operator will be better and faster in general than will inverse. Or use pinv, which will be more robust to problems.

woodchips
A: 

Hi I wanted to comment on Woodchips' answer but since I'm a new user I can't seem to do that, that is one very interesting article and I must read it in more detail when I have the time...

With regards to matrix inversion, you could always use the 'cond' command to calculate the condition number of the matrix, for a non-singular matrix the value should be approaching unity. As Woodchips suggested, 'pinv' does come in handy if you need to find the psuedo-inverse of a non-square matrix.

dpwave

related questions