![]() |
VOOZH | about |
In this article, we will use the cond() function of the NumPy package to calculate the condition number of a given matrix. cond() is a function of linear algebra module in NumPy package.
Syntax:
numpy.linalg.cond(x, p=None)
Example 1: Condition Number of 2X2 matrix
Output:
Original matrix: [[4 2] [3 1]] Condition number of the matrix: 14.933034373659256
Example 2: Condition Number of 3X3 matrix
Output:
Original matrix: [[4 2 0] [3 1 2] [1 6 4]] Condition number of the matrix: 5.347703616656448
Example 3: Condition Number of 4X4 matrix
Output:
Original matrix: [[4 1 4 2] [3 1 2 0] [3 5 7 1] [0 6 8 4]] Condition number of the matrix: 57.34043866386226