# Return the infinity Norm of the matrix in Linear Algebra using NumPy in Python

• Last Updated : 03 Jun, 2022

In this article, we will how to return the infinity Norm of the matrix in Linear Algebra in Numpy using Python.

## numpy.linalg.norm() method

The numpy.linalg.norm() method returns the matrix’s infinite norm in Python linear algebra. This function can return one of eight possible matrix norms or an infinite number of vector norms, depending on the value of the ord parameter. The infinity norm of a matrix is the maximum row sum, and the 1-norm is the maximum column sum after absolute values are taken. In other words, the infinity norm is the maximum row sum, while the 1-norm is the maximum column sum.

Syntax: numpy.linalg.norm(x, ord, axis):

Parameters:

• x: array of inputs. if ord is None, x must be 1-D or 2-D if axis is None. The 2-norm of x.ravel will be returned if both axis and ord are None.
• ord: non-zero int, inf, -inf, ‘fro’, ‘nuc’. (optional )
• axis: {None, int, 2-tuple of ints}. It is an optional parameter. If axis is an integer, it indicates the x-axis along which the vector norms should be computed.

Returns: float or ndarray, Norm of the matrix or vector is returned.

### Example 1

Here, the packages are imported and np.arrange() method is used to create an array. The .shape attribute finds the shape of the array, the .ndim attribute finds the dimension of the array, and the data type of the array is the .dtype attribute. np.linalg.norm() method is used to return the infinity Norm of the matrix. np. inf is given as the value for the ord parameter. The maximum row sum is returned.

## Python3

 `# import packages``import` `numpy.linalg as l``import` `numpy as np`` ` `# Creating an array``array ``=` `np.arange(``12``).reshape((``3``, ``4``))``print``(array)`` ` `# shape of the array is``print``(``"Shape of the array is : "``, array.shape)`` ` `# dimension of the array``print``(``"The dimension of the array is : "``, array.ndim)`` ` `# Datatype of the array``print``(``"Datatype of our Array is : "``, array.dtype)`` ` `# returning the infinity norm of the matrix``print``(l.norm(array, np.inf))`

Output:

```[[ 0  1  2  3]
[ 4  5  6  7]
[ 8  9 10 11]]
Shape of the array is :  (3, 4)
The dimension of the array is :  2
Datatype of our Array is :  int64
38.0```

### Example 2

In this example, np.linalg.norm() method is used to return the negative infinity Norm of the matrix. -np.inf is given as the value for the ord parameter. The minimum row sum is returned when we give -np.inf as ord, 6 is the minimum row sum of the below matrix.

## Python3

 `# import packages``import` `numpy.linalg as l``import` `numpy as np`` ` `# Creating an array``array ``=` `np.arange(``12``).reshape((``3``, ``4``))``print``(array)`` ` `# shape of the array is``print``(``"Shape of the array is : "``, array.shape)`` ` `# dimension of the array``print``(``"The dimension of the array is : "``, array.ndim)`` ` `# Datatype of the array``print``(``"Datatype of our Array is : "``, array.dtype)`` ` `# returning the infinity norm of the matrix``print``(l.norm(array, ``-``np.inf))`

Output:

```[[ 0  1  2  3]
[ 4  5  6  7]
[ 8  9 10 11]]
Shape of the array is :  (3, 4)
The dimension of the array is :  2
Datatype of our Array is :  int64
6.0```

My Personal Notes arrow_drop_up