5
$\begingroup$

The following returns 51/7, even though the condition number is actually 9. I'm curious, what does 51/7 correspond to for this matrix?

LinearAlgebra`Private`MatrixConditionNumber[{{7, 0, 0}, {0, 5, 4}, {0, 4, 5}}]

Wolfram Alpha returns the same result for the condition number of this matrix, as mentioned in this Twitter post.

$\endgroup$
10
  • 9
    $\begingroup$ It's an exact version of the infinity norm condition number estimate used by LUDecomposition: In[292]:= LUDecomposition[{{7, 0, 0}, {0, 5, 4}, {0, 4., 5}}][[3]] - 51/7 Out[292]= 8.88178*10^-16 $\endgroup$ Jan 5 at 21:34
  • 4
    $\begingroup$ The actual value is 9, yes. The estimate is from an iteration, I believe due to N. Higham. It does not compute an inverse or do any other O(n^3) operation, hence saves an order of magnitude in speed. $\endgroup$ Jan 6 at 4:46
  • 1
    $\begingroup$ I believe LAPACK's ?gecond is being used. FORTRAN code may be inspected; it's an iterative approximation as @Daniel mentions. W|A often does math over floating-point even when the input looks like exact integers to Mma users. Not sure the blame should be on W|A, since LAPACK is used widely by many different applications. $\endgroup$
    – Goofy
    Jan 6 at 17:53
  • 1
    $\begingroup$ Just to compare: MATLAB 1/rcond(A) returns 7.285714285714286. On a 10000 x 10000 matrix, rcond takes 5.2 sec.; cond(mat, 1) and cond(mat, inf) take about 13 sec. while cond(mat) (2-norm) takes nearly 33 sec. $\endgroup$
    – Goofy
    Jan 7 at 0:46
  • 1
    $\begingroup$ @Goofy why do you think it's gecond? I'm seeing 9 using gecond through scipy lapack wrapper -- import scipy 1/scipy.linalg.lapack.dgecon([[7.,0,0],[0,5,4],[0,4,5]], anorm=9, norm='I')[0] $\endgroup$ Jan 17 at 22:56

1 Answer 1

2
$\begingroup$

Extrapolating from how Matlab does it in comments, you also get $51/7$ from Lapack's dgecon applied to LU factorization of mat (dgetrf)

import scipy
mat=[[7.,0,0],[0,5,4],[0,4,5]]
lu=scipy.linalg.lapack.dgetrf(mat)[0]
eigs=scipy.linalg.eigh(mat)[0]
1/scipy.linalg.lapack.dgecon(lu, anorm=max(eigs), norm='I')[0] # 7.2857142857142865
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.