Python | sympy.div() method
The function
div()
provides division of polynomials with remainder. That is, for polynomials f and g, it computes q and r, such that
f= g*q+r
and
deg(r) <q.
Syntax:sympy.div(f, g, domain='QQ')
Return: division of polynomials with remainder
Example #1:
from sympy import *
f = 5 * x * * 2 + 10 * x + 3
g = 2 * x + 2
q, r = div(f, g, domain = 'QQ' )
print (q)
print (r)
|
Output:
5*x/2 + 5/2
-2
Example #2:
from sympy import *
f = 5 * x * * 2 + 10 * x + 3
g = 2 * x * * 2 + 2
q, r = div(f, g, domain = 'QQ' )
print (q)
print (r)
|
Output:
5/2
10*x - 2
Last Updated :
26 Aug, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...