Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • 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
  • 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 add one polynomial to another using NumPy in Python?
Next article icon

How to add one polynomial to another using NumPy in Python?

Last Updated : 29 Aug, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, Let's see how to add one polynomial to another. Two polynomials are given as input and the result is the addition of two polynomials.

  • The polynomial p(x) = C3 x2 + C2 x + C1  is represented in NumPy as : ( C1, C2, C3 ) { the coefficients (constants)}. 
  • Let take two polynomials p(x) and q(x) then add these to get r(x) = p(x) + q(x) as a result of addition of two input polynomials.
If p(x) = A3 x2 + A2 x + A1   and  q(x) = B3 x2 + B2 x + B1     then result is   r(x) = p(x) + q(x)   i.e;  r(x) = (A3 + B3) x2 + (A2 + B2) x + (A1 + B1)     and output is   ( (A1 + B1), (A2 + B2), (A3 + B3) )  

Below is the implementation with some examples :

Example 1: simple_use

Python3
# importing package import numpy  # define the polynomials # p(x) = 5(x**2) + (-2)x +5 px = (5,-2,5)  # q(x) = 2(x**2) + (-5)x +2 qx = (2,-5,2)  # add the polynomials rx = numpy.polynomial.polynomial.polyadd(px,qx)  # print the resultant polynomial print(rx) 

Output :

[ 7. -7.  7.]  

Example 2: #add_with_decimals

Python3
# importing package import numpy  # define the polynomials # p(x) = 2.2 px = (0,0,2.2)  # q(x) = 9.8(x**2) + 4 qx = (9.8,0,4)  # add the polynomials rx = numpy.polynomial.polynomial.polyadd(px,qx)  # print the resultant polynomial print(rx) 

Output :

[ 9.8  0.   6.2]  

Example 3: eval_then_add

Python3
# importing package import numpy  # define the polynomials # p(x) = (5/3)x px = (0,5/3,0)  # q(x) = (-7/4)(x**2) + (9/5) qx = (-7/4,0,9/5)  # add the polynomials rx = numpy.polynomial.polynomial.polyadd(px,qx)  # print the resultant polynomial print(rx) 

Output :

[-1.75        1.66666667  1.8       ]  

Next Article
How to add one polynomial to another using NumPy in Python?

D

deepanshu_rustagi
Improve
Article Tags :
  • Python
  • Python-numpy
  • Python numpy-Mathematical Function
Practice Tags :
  • python

Similar Reads

    How to subtract one polynomial to another using NumPy in Python?
    In this article, let's discuss how to subtract one polynomial to another. Two polynomials are given as input and the result is the subtraction of two polynomials. The polynomial p(x) = C3 x2 + C2 x + C1  is represented in NumPy as : ( C1, C2, C3 ) { the coefficients (constants)}.Let take two polynom
    2 min read
    How to divide a polynomial to another using NumPy in Python?
    In this article, we will make a NumPy program to divide one polynomial to another. Two polynomials are given as input and the result is the quotient and remainder of the division. The polynomial p(x) = C3 x2 + C2 x + C1  is represented in NumPy as : ( C1, C2, C3 ) { the coefficients (constants)}.Let
    2 min read
    How to multiply a polynomial to another using NumPy in Python?
    In this article, we will make a NumPy program to multiply one polynomial to another. Two polynomials are given as input and the result is the multiplication of two polynomials. The polynomial p(x) = C3 x2 + C2 x + C1  is represented in NumPy as : ( C1, C2, C3 ) { the coefficients (constants)}.Let ta
    2 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
    Convert a polynomial to Hermite_e series using NumPy in Python
    In this article, we will cover how to convert a polynomial to Hermite_e series using NumPy in Python. hermite_e.poly2herme method We use the hermite_e.poly2herme() function present in the NumPy module of python to convert a polynomial to a Hermite series. Here we need to convert an array of polynomi
    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