Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Return the negative infinity Norm of the matrix in Linear Algebra in Python
To return the negative infinity norm of a matrix in Linear Algebra, use the LA.norm() method with -np.inf as the order parameter. The negative infinity norm returns the minimum row sum of absolute values in the matrix.
Syntax
numpy.linalg.norm(x, ord=-np.inf, axis=None, keepdims=False)
Parameters
The key parameters for calculating negative infinity norm ?
- x − Input array (1-D or 2-D)
-
ord − Order of norm. Use
-np.inffor negative infinity norm - axis − Axis along which to compute the norm (default: None)
- keepdims − Whether to keep dimensions in result (default: False)
How Negative Infinity Norm Works
The negative infinity norm calculates the minimum of the sum of absolute values across each row of the matrix. For a matrix with rows containing absolute sums [9, 2, 9], the negative infinity norm would be 2 (the minimum value).
Example
import numpy as np
from numpy import linalg as LA
# Create a matrix
arr = np.array([[-4, -3, -2],
[-1, 0, 1],
[ 2, 3, 4]])
# Display the array
print("Our Array:")
print(arr)
# Check array properties
print("\nDimensions:", arr.ndim)
print("Datatype:", arr.dtype)
print("Shape:", arr.shape)
# Calculate negative infinity norm
result = LA.norm(arr, -np.inf)
print("\nNegative Infinity Norm:", result)
# Show row sums for understanding
row_sums = np.sum(np.abs(arr), axis=1)
print("Row sums of absolute values:", row_sums)
print("Minimum row sum (negative inf norm):", np.min(row_sums))
Our Array: [[-4 -3 -2] [-1 0 1] [ 2 3 4]] Dimensions: 2 Datatype: int64 Shape: (3, 3) Negative Infinity Norm: 2.0 Row sums of absolute values: [9 2 9] Minimum row sum (negative inf norm): 2.0
Comparison with Other Norms
| Norm Type | Parameter | Calculation | Result |
|---|---|---|---|
| Negative Infinity | -np.inf |
Min of row sums | 2.0 |
| Infinity | np.inf |
Max of row sums | 9.0 |
| Frobenius | 'fro' |
Square root of sum of squares | 7.75 |
Conclusion
The negative infinity norm using LA.norm(matrix, -np.inf) returns the minimum row sum of absolute values. This norm is useful in optimization and numerical analysis for measuring matrix properties.
