Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Numpy exercise
  • pandas
  • Matplotlib
  • Data visulisation
  • EDA
  • Machin Learning
  • Deep Learning
  • NLP
  • Data science
  • ML Tutorial
  • Computer Vision
  • ML project
Open In App
Next Article:
How to get the number of dimensions of a matrix using NumPy in Python?
Next article icon

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

Last Updated : 03 Jun, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

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

Next Article
How to get the number of dimensions of a matrix using NumPy in Python?
author
isitapol2002
Improve
Article Tags :
  • Python
  • Python-numpy
  • Python numpy-Linear Algebra
Practice Tags :
  • python

Similar Reads

  • Return the Norm of the vector over given axis in Linear Algebra using NumPy in Python
    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,
    3 min read
  • Raise a square matrix to the power n in Linear Algebra using NumPy in Python
    In this article, we will discuss how to raise a square matrix to the power n in the Linear Algebra in Python. The numpy.linalg.matrix_power() method is used to raise a square matrix to the power n. It will take two parameters, The 1st parameter is an input matrix that is created using a NumPy array
    3 min read
  • Integrate Legendre series and set the lower bound of the integral using NumPy in Python
    In this article, we will see how to integrate a Legendre series and set the lower bound of the integral in Python using NumPy. To perform Legendre integration, NumPy provides a function called legendre.legint which can be used to integrate Legendre series. Syntax: legendre.legint(c, lbnd=0, scl=1, a
    3 min read
  • How to get the number of dimensions of a matrix using NumPy in Python?
    In this article, we will discuss how to get the number of dimensions of a matrix using NumPy. It can be found using the ndim parameter of the ndarray() method. Syntax: no_of_dimensions = numpy.ndarray.ndim Approach: Create an n-dimensional matrix using the NumPy package.Use ndim attribute available
    3 min read
  • Integrate a Chebyshev series and set the lower bound of the integral using NumPy in Python
    In this article, we will see how to integrate a Chebyshev series and set the lower bound of the integral in Python using Numpy. To perform Chebyshev integration, NumPy provides a function called chebyshev.chebint which can be used to integrate Legendre series. Syntax: chebyshev.chebint(c, lbnd=0, sc
    3 min read
  • Generate a Vandermonde matrix of the Legendre series in Python using NumPy
    In this article, we will be looking toward the approach to generating a Vandermonde matrix of the Legendre series in Python using NumPy. Example: Array: [-1 2 -3 4 -5] Result: [[ 1. -1. 1. ] [ 1. 2. 5.5] [ 1. -3. 13. ] [ 1. 4. 23.5] [ 1. -5. 37. ]]NumPy.legvander() To generate a pseudo Vandermonde m
    3 min read
  • How to get the indices of the sorted array using NumPy in Python?
    We can get the indices of the sorted elements of a given array with the help of argsort() method. This function is used to perform an indirect sort along the given axis using the algorithm specified by the kind keyword. It returns an array of indices of the same shape as arr that would sort the arra
    2 min read
  • Return the scaled companion matrix of a 1-D array of Chebyshev series coefficients using NumPy in Python
    In this article, we will discuss how to return the scaled companion matrix of a 1D array of Chebyshev series coefficients in python. chebyshev.chebcompanion() method  chebyshev.chebcompanion() method provides the eigenvalue estimates than the unscaled case and for basis polynomials. We can say that
    3 min read
  • Multiplication of two Matrices in Single line using Numpy in Python
    Matrix multiplication is an operation that takes two matrices as input and produces single matrix by multiplying rows of the first matrix to the column of the second matrix.In matrix multiplication make sure that the number of columns of the first matrix should be equal to the number of rows of the
    3 min read
  • Compute the determinant of a given square array using NumPy in Python
    In Python, the determinant of a square array can be easily calculated using the NumPy package. This package is used to perform mathematical calculations on single and multi-dimensional arrays. numpy.linalg is an important module of NumPy package which is used for linear algebra. We can use det() fun
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences