# Matrix condition number

In[1]:= $Version Out[1]= "12.3.1 for Microsoft Windows (64-bit) (June 19, 2021)" In[2]:= (* Case 1 *) SeedRandom[1235]; mat1 = RandomInteger[{-1000, 1000}, {100, 100}]; A1 = N[1/2*(mat1 + mat1\[Transpose])]; lhs = Max[Total[Abs[#]] & /@ A1]*Max[Total[Abs[#]] & /@ Inverse[A1]] (* condition number = (Infinity norm of A)*(Infinity norm of A^-1) *) rhs1 = Last[LUDecomposition[A1]] rhs2 = LinearSolve[A1]["ConditionNumber"] rhs3 = LinearAlgebraPrivateMatrixConditionNumber[A1] lhs == rhs1 == rhs2 == rhs3 Out[5]= 6015.53 Out[6]= 6015.53 Out[7]= 6015.53 Out[8]= 6015.53 Out[9]= True  Now let's generate a different matrix. In[10]:= (* Case 2 *) SeedRandom[1234]; mat2 = RandomInteger[{-1000, 1000}, {100, 100}]; A2 = N[1/2*(mat2 + mat2\[Transpose])]; lhs = Max[Total[Abs[#]] & /@ A2]*Max[Total[Abs[#]] & /@ Inverse[A2]] rhs1 = Last[LUDecomposition[A2]] rhs2 = LinearSolve[A2]["ConditionNumber"] rhs3 = LinearAlgebraPrivateMatrixConditionNumber[A2] lhs == rhs1 == rhs2 == rhs3 Out[13]= 4142.83 Out[14]= 4035.24 Out[15]= 4035.24 Out[16]= 4035.24 Out[17]= False  Why is the computed condition number different in the two cases? • Why should the condition number for 2 random matrices be the same? Dec 8 '21 at 17:50 • My apology - I meant the condition number is the same for case 1 computed using the four methods but it is different in case 2 computed using the same four methods. The only difference is in the generation of the random matrices. Dec 8 '21 at 18:04 • The first computation uses the definition whereas the rest use approximate methods that are generally faster than computing the inverse. The surprise to me is that all four are equal in one case. Dec 9 '21 at 0:57 • Daniel Lichtblau got it; the last three use variations of the Hager-Higham estimator (which LAPACK also uses). That method often gives results close to the$\infty\$-norm condition number, but not always. Dec 9 '21 at 18:23
• Got it - thanks to you both. Dec 9 '21 at 18:53