numpy.polydiv() in Python

numpy.polydiv(p1, p2) method evaluates the division of two polynomials and returns the quotient and remainder of the polynomial division.

Parameters :
p1 : [array_like or poly1D]Coefficients of dividend polynomial.
p2 : [array_like or poly1D]Coefficients of divisor polynomial.

Return:
q : [ndarray]Coefficients of quotient.
r : [ndarray]Coefficients of remainder.

Code : Python code explaining polydiv()

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python code explaining 
# numpy.polydiv()
    
# importing libraries
import numpy as np
import pandas as pd
  
# Constructing polynomial 
p1 = np.poly1d([1, 2]) 
p2 = np.poly1d([4, 9, 5, 4]) 
    
print ("P1 : ", p1) 
print ("\n p2 : \n", p2) 

chevron_right


filter_none

edit
close

play_arrow

link
brightness_4
code

quotient, remainder = np.polydiv(p2, p1)
  
print("\n\nquotient  : ", quotient)
print("remainder : ", remainder)
print ("\n")

chevron_right


filter_none

edit
close

play_arrow

link
brightness_4
code

# Defining ndarray
x = np.array([1, 2])
y = np.array([4, 9, 5, 4])
  
quotient, remainder = np.polydiv(y, x)
  
print("quotient  : ", quotient)
print("remainder : ", remainder)

chevron_right




My Personal Notes arrow_drop_up

Aspire to Inspire before I expire

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.