numpy.polyadd () in Python

Parameters :

  p1:  Input polynomial 1  p2:  Input polynomial 2 

Return:

 Sum of polynomials 

# Python code explaining
# numpy.polyadd ()

 
# import libraries

import numpy as np

 

p1 = np.poly1d ([ 1 , 2 ])

p2 = np.poly1d ([ 9 , 5 , 4 ])

 

print ( "P1:" , p1)

print ( "P2:" , p2)

 

a = np.polyadd (p1, p2)

 

print ( " P1 + P2: " , a)

Output:

 P1: 1 x + 2 P2: 2 9 x + 5 x + 4 P1 + P2: 2 9 x + 6 x + 6