Friday, October 10, 2025
HomeLanguagesnumpy.polysub() in Python

numpy.polysub() in Python

numpy.polysub() :This function helps to find the difference 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 :  1x + 2.
p2 : Input polynomial 2 :  9x2 + 5x + 4

Return:

Difference of polynomials :  (0-9)x2 + (1-5)x + (2-4)




# Python code explaining 
# numpy.polysub ()
  
# 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.polysub(p1, p2)
  
print ("\nP1 - P2 : \n", a)


Output:

P1 :   
1 x + 2

P2 : 
    2
9 x + 5 x + 4

P1 - P2 : 
     2
-9 x - 4 x - 2
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32349 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6715 POSTS0 COMMENTS
Nicole Veronica
11878 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6837 POSTS0 COMMENTS
Ted Musemwa
7097 POSTS0 COMMENTS
Thapelo Manthata
6792 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS