help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inverse Matrix Function appears a bit wonky


From: Henry F. Mollet
Subject: Re: Inverse Matrix Function appears a bit wonky
Date: Wed, 03 Nov 2004 14:56:39 -0800
User-agent: Microsoft-Entourage/10.1.1.2418

I guess that older version don't give a warning. I have 2.1.46. The
determinant is zero and the inverse of A is defined as A-1 = adj A/det A.
Henry
testmatrix =

  1  2  3  4
  2  2  3  3
  1  2  1  2
  3  2  2  1

octave:51> testmatrixinv = inverse(testmatrix)
testmatrixinv =

   -4.5036e+15    6.0048e+15    1.5012e+15   -3.0024e+15
    4.5036e+15   -6.0048e+15   -1.5012e+15    3.0024e+15
    4.5036e+15   -6.0048e+15   -1.5012e+15    3.0024e+15
   -4.5036e+15    6.0048e+15    1.5012e+15   -3.0024e+15

octave:52> testmatrixinv*testmatrix
ans =

   3.00000   1.00000   2.00000   0.00000
   1.50000   1.00000  -1.00000   0.50000
   0.00000   0.00000   0.00000   1.00000
   0.50000   0.00000  -1.00000  -0.50000

octave:53> det(testmatrix)
ans =  -1.3323e-15
octave:54> rank(testmatrix)
ans = 3



on 11/3/04 1:07 PM, John W. Eaton at address@hidden wrote:

> On  3-Nov-2004, Robert A. Macy <address@hidden> wrote:
> 
> | I tried a simple test of the inverse function using a "made
> | up" matrix...
> | 
> | testmatrix =
> |  1 2 3 4
> |  2 2 3 3
> |  1 2 1 2
> |  3 2 2 1
> | 
> | forgive the wraparound results...
> | testmatrixinv = inverse(testmatrix) =
> |  -3.37769972052787e+15 4.5035996273705e+15
> | 1.12589990684262e+15 -2.25179981368525e+15
> | 
> |  3.37769972052787e+15 -4.5035996273705e+15
> | -1.12589990684262e+15 2.25179981368525e+15
> | 
> |  3.37769972052787e+15 -4.5035996273705e+15
> | -1.12589990684262e+15 2.25179981368525e+15
> | 
> |  -3.37769972052787e+15 4.5035996273705e+15
> | 1.12589990684262e+15 -2.25179981368525e+15
> | 
> | inverse function merrily calculated the above inverse
> | matrix with no special notes.
> | 
> | but when I multiply the two, the results are...
> | testmatrixinv*testmatrix =
> |  1 0 1 -1
> |  0 1 0 1.5
> |  -1 -0.5 1 1
> |  1 0.5 0.5 0.25
> |  
> | which is definitely NOT the identity matrix
> | 
> | the testmatrix was just an arbitrary matrix to test the
> | process.  It is very disconcerting that the first,
> | arbitrary test, fails so miserably.  What happened?
> | 
> | What do I do to make certain octave doesn't do these
> | erroneous inverse calculations the next time I go to use
> | the inverse function?
> 
> Your test matrix is singular.  The inverse doesn't exist.  Octave
> should be warning you about that.  Here is what I see with Octave
> 2.1.57 and 2.1.60, and probably almost every other version of Octave
> that *I* have ever used:
> 
> octave:1> x = [1 2 3 4
>>  2 2 3 3
>>  1 2 1 2
>>  3 2 2 1];
> octave:2> rank (x)
> ans = 3
> octave:3> inverse (x)
> warning: inverse: matrix singular to machine precision, rcond = 0
> ans =
> 
>   3.00000  2.00000  2.00000  1.00000
>   0.33333  1.33333  0.33333  1.66667
>   0.33333  1.00000  2.00000  2.00000
>   0.66667  0.50000  0.75000  0.00000
> 
> The above result is from a version of Octave linked with ATLAS for the
> linear algebra routines.
> 
> What version of Octave are you using?  What LAPACK+BLAS combination
> does it use?  If there is no warning on your system, I suspect your
> version of Octave is linked with some version of LAPACK that does not
> return the proper error code when a singular matrix is detected during
> the factorizaion leading to the computation of the inverse.
> 
> jwe
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]