inconsistent condition numbers from cond, det, inv functions

Ben Abbott bpabbott at mac.com
Thu Feb 7 03:45:07 CST 2008


On Feb 7, 2008, at 4:28 AM, Rolf Fabian wrote:

>
> octave-3.0.0.exe:> version, computer
> ans = 3.0.0
> i686-pc-msdosmsvc
>
> # a singular matrix
> octave-3.0.0.exe:> x=[1,2,3;2,3,4;3,4,5]
> x =
>   1   2   3
>   2   3   4
>   3   4   5
>
> octave-3.0.0.exe:> [dum,rc1]=det(x)
> dum = 0
> rc1 = 2.3130e-018
>
> octave-3.0.0.exe:> [dum,rc2]=inv(x); rc2
> rc2 = 2.3130e-018
>
> octave-3.0.0.exe:> rc3 = 1./cond(x)
> rc3 = 4.1351e-017
>
> The help parts of 'det' and 'inv' do not explain
> whether a different definition of condition
> number than 'cond' is used during evaluation.
>
> Thus all results of 'rc' are expected to be
> identical, but result from 1/cond(x) differs
> unfortunately. Needs to be fixed.
>
> No idea what MatLab returns for the
> three cases. Probably somebody has the
> time to check it.

Matlab's det() and inv() only supply one output.

 >> x=[1,2,3;2,3,4;3,4,5]

x =

      1     2     3
      2     3     4
      3     4     5

 >>  [dum,rc1]=det(x)
??? Error using ==> det
Too many output arguments.

 >> help det
  DET    Determinant.
     DET(X) is the determinant of the square matrix X.

     Use COND instead of DET to test for matrix singularity.

     See also cond.

     Reference page in Help browser
        doc det

 >> [dum,rc2]=inv(x); rc2
??? Error using ==> inv
Too many output arguments.

 >> help inv
  INV    Matrix inverse.
     INV(X) is the inverse of the square matrix X.
     A warning message is printed if X is badly scaled or
     nearly singular.

     See also slash, pinv, cond, condest, lsqnonneg, lscov.

     Overloaded methods:
        scmapinv/inv
        scmap/inv
        moebius/inv
        composite/inv

     Reference page in Help browser
        doc inv

 >>  rc3 = 1./cond(x)

rc3 =

    3.1013e-17

My octave gives the same answer as yours.

octave:48> x=[1,2,3;2,3,4;3,4,5]
x =

    1   2   3
    2   3   4
    3   4   5

octave:49> 1/cond(x)
ans =  4.1351e-17
octave:50>

Ben


More information about the Bug-octave mailing list