Search code examples
pythonnumpymatrixeigenvalue

Is numpy.linalg.cond returning the ratio of the biggest and smallest eigenvalue?


I need to calculate the ratio of the biggest and smallest eigenvalue of a matrix, which is called "condition number" as far as I know. I have found the numpy.linalg.cond that computes the condition number of a matrix, but I was wondering if this actually corresponds to the ratio between the biggest and smallest eigenvalues. Can someone give me indications on that?


Solution

  • According to the documentation np.linalg.cond is defined as the norm of the array times the inverse of the norm of the array which is not what you are looking for. But what you want can easily be done:

        import numpy as np
    
        Eigs = np.linalg.eigvals(yourarrayhere)
        cond = np.max(Eigs)/np.min(Eigs)