Open In App

numpy.polyadd() in Python

Last Updated : 29 Nov, 2018
Improve
Improve
Like Article
Like
Save
Share
Report

numpy.polyadd() : This function helps to find the sum of two polynomials and then returning the result as a polynomial. Each input polynomial must be a sequence of polynomial coefficients, from highest to lowest degree.

Parameters :

p1 : Input polynomial 1
p2 : Input polynomial 2

Return :

Sum of polynomials




# Python code explaining 
# numpy.polyadd ()
  
# importing libraries
import numpy as np
  
p1 = np.poly1d([1, 2])
p2 = np.poly1d([9, 5, 4])
  
print ("P1 : ", p1)
print ("\nP2 : \n", p2)
  
a = np.polyadd(p1, p2)
  
print ("\nP1 + P2 : \n", a)


Output :

P1 :   
1 x + 2

P2 : 
    2
9 x + 5 x + 4

P1 + P2 : 
    2
9 x + 6 x + 6

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads