# How to Compute the Condition Number in Python?

The condition number is a measure of the sensitivity of a mathematical problem to changes in its input. In Python, you can compute the condition number of a matrix using the NumPy library. Here’s an example:

``````import numpy as np

# Define a matrix
A = np.array([[1, 2], [3, 4]])

# Compute the condition number
condition_number = np.linalg.cond(A)

print("Condition number:", condition_number)``````

In this example, the NumPy library is imported to work with arrays and linear algebra functions. The matrix `A` is defined as a NumPy array. The `np.linalg.cond()` function is then used to compute the condition number of the matrix `A`. The result is stored in the `condition_number` variable and printed.

Make sure to have NumPy installed (`pip install numpy`) before running this code. Additionally, note that the condition number is only defined for square matrices. If you have a non-square matrix, you may need to consider other approaches or matrix decompositions to assess its properties