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:
Integrate a Chebyshev series and set the order of integration using NumPy in Python
Next article icon

Integrate a Legendre series over axis 0 using NumPy in Python

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

In this article, we will cover how to integrate a Legendre series over axis 0 using NumPy in Python.

polynomial.legendre.legint method

The polynomial.legendre.legint() method from the NumPy library is used to Integrate a Legendre series over axis 0 in python.The resulting series is multiplied by scl and an integration constant, k, is added at each iteration. The scaling factor is intended for usage in linear variable changes.  The argument c is an array of coefficients ranging in degree from low to high along each axis, for example, [4,3,1] represents the series 4. If axis=0 is x and axis=1 is y, [[2,1],[2,1]] symbolises 2*L 0(x)*L 0(y) + 2*L 1(x)*L 0(y) + 1*L 0(x)*L 1(y) + 1*L 1(x)*L 1(y) + 1*L 1(x)*L 1(y) + 1*L

Syntax: polynomial.legendre.legint(c, m=1, scl=1, axis=0)

Parameters:

  • c: array like object. 
  • m: int, optional value.The integration order must be positive. Standard value is 1.
  • axis: optional value,int. The axis on which the integral is computed. The default value is 0.

Returns: Legendre series coefficient array of the integral.

Example 1:

Here, we will create a NumPy array and use polynomial.legendre.legint() to Integrate a Legendre series over axis 0 in python. The shape of the array is found by the .shape attribute, the dimension of the array is found by .ndim attribute, and the data type of the array is .dtype attribute. even if we don't specify by default axis is set to '0'.

Python3
# import packages import numpy as np from numpy.polynomial import legendre as L  # array of coefficients array1 = np.array([1,2,3,4,5]) print(array1)  # shape of the array is print("Shape of array1 is: ", array1.shape)  # dimension of the array print("The dimension of array1 is: ", array1.ndim)  # datatype of the array print("Datatype of Array1 is: ", array1.dtype)  # adding two hermite series along axis =0 print('Integrating the legendre series : ') print(L.legint(array1,axis=0)) 

Output:

[1 2 3 4 5]

Shape of array1 is:  (5,)

The dimension of array1 is:  1

Datatype of Array1 is:  int64

Integrating the legendre series : 

[-0.16666667  0.4         0.0952381   0.04444444  0.57142857  0.55555556]

Example 2:

In this example, we specify axis =1, which represents that we're integrating according to columns.

Python3
# import packages import numpy as np from numpy.polynomial import legendre as L  # array of coefficients array1 = np.array([[1,2,3,4,5],[6,7,8,9,10]]) print(array1)  # shape of the array is print("Shape of array1 is: ", array1.shape)  # dimension of the array print("The dimension of array1 is: ", array1.ndim)  # datatype of the array print("Datatype of Array1 is: ", array1.dtype)  # adding two hermite series print('Integrating the legendre series : ') print(L.legint(array1,axis=1)) 

Output:

[[ 1  2  3  4  5]

 [ 6  7  8  9 10]]

Shape of array1 is:  (2, 5)

The dimension of array1 is:  2

Datatype of Array1 is:  int64

Integrating the legendre series : 

[[-0.16666667  0.4         0.0952381   0.04444444  0.57142857  0.55555556]

 [ 0.04166667  4.4         1.04761905  0.48888889  1.28571429  1.11111111]]


Next Article
Integrate a Chebyshev series and set the order of integration using NumPy in Python
author
isitapol2002
Improve
Article Tags :
  • Python
  • Python-numpy
  • Python numpy-polynomials
Practice Tags :
  • python

Similar Reads

  • Integrate a Hermite_e series Over Axis 0 using Numpy in Python
    In this article, we will cover how to integrate a Hermite_e series over axis 0 using NumPy in Python. NumPy e.hermeint() method  We use the hermite e.hermeint() function present in the NumPy module of python to integrate a Hermite e series. The first parameter 'arr' is an array of coefficients from
    2 min read
  • Differentiate a Legendre series using NumPy in Python
    In this article, we will cover how to differentiate a Legendre series in Python using NumPy. legendre.legder method In python, the Legendre module provides many functions like legder to perform arithmetic, and calculus operations on the Legendre series. It is one of the functions provided by the Leg
    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
  • Integrate a Chebyshev series and set the order of integration using NumPy in Python
    In this article, we will discuss how to integrate the Chebyshev series and set the order of integration in Python and NumPy. chebyshev.chebint method Chebyshev polynomials are significant in approximation theory because the Chebyshev nodes are used as matching points for optimizing polynomial interp
    4 min read
  • Differentiate a Legendre series and set the derivatives using NumPy in Python
    In this article, we will cover how to differentiate a Legendre series and set the derivatives using NumPy in Python. numpy.polynomial.legendre.legder The numpy.polynomial.legendre.legder() method from the NumPy library is used to differentiate a Legendre series and set the derivatives in Python. The
    3 min read
  • Add one Hermite series to another using NumPy in Python
    In this article, we will cover how to add one Hermite series to another using NumPy in Python. np.polynomial.hermite.hermadd method The numpy.polynomial.hermite.hermadd() method from the NumPy library is used to add one Hermite series to another. The sum of two Hermite series (c1 + c2) is returned.
    3 min read
  • Evaluate a 2D Laguerre series at points (x,y) using NumPy in Python
    In this article, we will discuss how to evaluate a 2D Laguerre series at points (x,y) using NumPy in Python. Example Input: [[[ 0 1 2] [ 3 4 5] [ 6 7 8]] [[ 9 10 11] [12 13 14] [15 16 17]] [[18 19 20] [21 22 23] [24 25 26]]] Output: [[[1920. 522.] [ 414. 108.]] [[2020. 552.] [ 444. 117.]] [[2120. 58
    3 min read
  • Evaluate a 3D Laguerre series at points (x,y,z) using NumPy in Python
    In this article, we will cover how to evaluate a 3D Laguerre series at points (x,y,z) using NumPy in Python. numpy.polynomial.legendre.legval3d The numpy.polynomial.legendre.legval3d() method from the NumPy library is used to evaluate a 3D Laguerre series at points(x,y,z) in Python. Only tuples or l
    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
  • Evaluate a Hermite_e series at points x in using NumPy Python
    In this article, we will cover how to evaluate a Hermite_e series at points x using NumPy in Python. numpy.polynomial.hermite.hermval The numpy.polynomial.hermite.hermval() method from the NumPy library is used to evaluate a Hermite series at points x. If the parameter x is a tuple or a list, it is
    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