# Return the Frobenius Norm of the matrix in Linear Algebra in Python

To return the Norm of the matrix or vector in Linear Algebra, use the LA.norm() method in Python Numpy. The 1st parameter, x is an input array. If axis is None, x must be 1-D or 2-D, unless ord is None. If both axis and ord are None, the 2-norm of x.ravel will be returned.

The 2nd parameter, ord is the order of the norm. The inf means numpy’s inf object. The default is None. The "fro" set as a parameter is the Frobenius norm. Both the Frobenius and nuclear norm orders are only defined for matrices

## Steps

At first, import the required library −

import numpy as np
from numpy import linalg as LA

Create an array −

arr = np.array([[ -4, -3, -2], [-1, 0, 1], [2, 3, 4] ])

Display the array −

print("Our Array...\n",arr)

Check the Dimensions −

print("\nDimensions of our Array...\n",arr.ndim)

Get the Datatype −

print("\nDatatype of our Array object...\n",arr.dtype)

Get the Shape −

print("\nShape of our Array object...\n",arr.shape)

To return the Norm of the matrix or vector in Linear Algebra, use the LA.norm() method in Python Numpy −

print("\nResult...\n",LA.norm(arr, 'fro'))

## Example

import numpy as np
from numpy import linalg as LA

# Create an array
arr = np.array([[ -4, -3, -2], [-1, 0, 1], [2, 3, 4] ])

# Display the array
print("Our Array...\n",arr)

# Check the Dimensions
print("\nDimensions of our Array...\n",arr.ndim)

# Get the Datatype
print("\nDatatype of our Array object...\n",arr.dtype)

# Get the Shape
print("\nShape of our Array object...\n",arr.shape)

# To return the Norm of the matrix or vector in Linear Algebra, use the LA.norm() method in Python Numpy
print("\nResult...\n",LA.norm(arr, 'fro'))

## Output

Our Array...
[[-4 -3 -2]
[-1 0 1]
[ 2 3 4]]

Dimensions of our Array...
2

Datatype of our Array object...
int64

Shape of our Array object...
(3, 3)

Result...
7.745966692414834