Return the Norm of the vector over given axis in Linear Algebra using NumPy in Python Last Updated : 05 Jun, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will how to return the Norm of the vector over a given axis in Linear Algebra in Python. numpy.linalg.norm() method The numpy.linalg.norm() method is used to return the Norm of the vector over a given axis in Linear algebra in Python. Depending on the value of the ord parameter, this function can return one of the possible matrix norms or one of an unlimited number of vector norms. The Euclidean distance of a vector from the origin, A norm known as the Euclidean norm, or 2-norm, which can also be defined as the square root of the inner product of a vector with itself. axis =0 is used to find the norm along the rows and axis =1 is used to find the norm along with the columns. Below is the syntax of linalg.norm, In this the first parameter should be a 1-D or 2-D array whereas ord is the order of the norm and the axis computes the vector norms along with the axis: Syntax: numpy.linalg.norm(x, ord, axis): Parameters: x: array of inputs Unless 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}.If axis is an integer, it indicates the x-axis along which the vector norms should be computed. (optional ) 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 Norm of the vector according to the axis given. axis=0 represents that we're finding the norm of the vector along rows. Python3 # import packages import numpy.linalg as l import numpy as np # Creating an array array = np.arange(12) 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 norm of the vector over axis 0. print(l.norm(array, axis=0)) Output: [ 0 1 2 3 4 5 6 7 8 9 10 11] Shape of the array is : (12,) The dimension of the array is : 1 Datatype of our Array is : int64 22.494443758403985Example 2: In this example, the input is a matrix and the norm of the matrix is found, by specifying axis =1. It represents along with columns. 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 norm of the matrix along axis 1 print(l.norm(array, axis=1)) 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 [ 3.74165739 11.22497216 19.13112647] Comment More infoAdvertise with us Next Article Return the Norm of the vector over given axis in Linear Algebra using NumPy in Python I isitapol2002 Follow Improve Article Tags : Python Python-numpy Python numpy-Linear Algebra Practice Tags : python Similar Reads Python Tutorial - Learn Python Programming Language Python is one of the most popular programming languages. Itâs simple to use, packed with features and supported by a wide range of libraries and frameworks. Its clean syntax makes it beginner-friendly. It'sA high-level language, used in web development, data science, automation, AI and more.Known fo 10 min read Python Interview Questions and Answers Python is the most used language in top companies such as Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase, Spotify and many more because of its simplicity and powerful libraries. To crack their Online Assessment and Interview Rounds as a Python developer, we need to master important Pyth 15+ min read Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read Python OOPs Concepts Object Oriented Programming is a fundamental concept in Python, empowering developers to build modular, maintainable, and scalable applications. By understanding the core OOP principles (classes, objects, inheritance, encapsulation, polymorphism, and abstraction), programmers can leverage the full p 11 min read Python Projects - Beginner to Advanced Python is one of the most popular programming languages due to its simplicity, versatility, and supportive community. Whether youâre a beginner eager to learn the basics or an experienced programmer looking to challenge your skills, there are countless Python projects to help you grow.Hereâs a list 10 min read Python Exercise with Practice Questions and Solutions Python Exercise for Beginner: Practice makes perfect in everything, and this is especially true when learning Python. If you're a beginner, regularly practicing Python exercises will build your confidence and sharpen your skills. To help you improve, try these Python exercises with solutions to test 9 min read Python Programs Practice with Python program examples is always a good choice to scale up your logical understanding and programming skills and this article will provide you with the best sets of Python code examples.The below Python section contains a wide collection of Python programming examples. These Python co 11 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read Python Introduction Python was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was designed with focus on code readability and its syntax allows us to express concepts in fewer lines of code.Key Features of PythonPythonâs simple and readable syntax makes it beginner-frien 3 min read Python Data Types Python Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, Python data types are classes and variables are instances (objects) of thes 9 min read Like