- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Divide one polynomial by another in Python

To divide one polynomial by another, use the numpy.polynomial.polynomial.polydiv() method in Python. Returns the quotient-with-remainder of two polynomials c1 / c2. The arguments are sequences of coefficients, from lowest order term to highest, e.g., [1,2,3] represents 1 + 2*x + 3*x**2.

The method returns the array of coefficient series representing the quotient and remainder. The parameters c1 and c2 are the 1-D arrays of coefficients representing a polynomial, relative to the “standard” basis, and ordered from lowest order term to highest.

This numpy.polynomial.polynomial module provides a number of objects useful for dealing with polynomials, including a Polynomial class that encapsulates the usual arithmetic operations.

## Steps

At first, import the required libraries −

from numpy.polynomial import polynomial as P

Declare Two Polynomials −

p1 = (4,1,6) p2 = (2,5,3)

Display the polynomials −

print("Polynomial 1...\n",p1) print("\nPolynomial 2...\n",p2)

To divide one polynomial by another, use the numpy.polynomial.polynomial.polydiv() method in Python −

mulRes = P.polydiv(p1,p2); print("\nResult (divide)...\n",mulRes)

## Example

from numpy.polynomial import polynomial as P # Declare Two Polynomials p1 = (4,1,6) p2 = (2,5,3) # Display the polynomials print("Polynomial 1...\n",p1) print("\nPolynomial 2...\n",p2) # To divide one polynomial by another, use the numpy.polynomial.polynomial.polydiv() method in Python. mulRes = P.polydiv(p1,p2); print("\nResult (divide)...\n",mulRes)

## Output

Polynomial 1... (4, 1, 6) Polynomial 2... (2, 5, 3) Result (divide)... (array([2.]), array([ 0., -9.]))

- Related Questions & Answers
- Divide one Hermite series by another in Python
- Divide one Laguerre series by another in Python
- Divide one Legendre series by another in Python
- Divide one Chebyshev series by another in Python
- Divide one Hermite_e series by another in Python
- Add one polynomial to another in Python
- Subtract one polynomial to another in Python
- Multiply one polynomial to another in Python
- Divide one BigInteger from another BigInteger in Java
- Java Program to divide one BigDecimal from another BigDecimal
- Program to check one string can be converted to another by removing one element in Python
- Add one Python string to another
- Divide every element of one array by other array elements in C++ Program
- Python - First occurrence of one list in another
- Add one Chebyshev series to another in Python