# Polynomial division command

hello I found this post from sage documents for division of two polynomials

def division(dividend, divisor) :
print 'quotient: ', (dividend._maxima_().divide(divisor).sage())[0]
print 'remainder: ', (dividend._maxima_().divide(divisor).sage())[1]


edit retag close merge delete

Perhaps [this](http://199.219.158.222/home/pub/0/) is the post you mention.

( 2013-04-02 17:08:19 +0200 )edit

Sort by ยป oldest newest most voted

The dividend._maxima_() returns the coercion of dividend to an object of the maxima interface. It seems it is only used to access the divide method, as symbolic expressions don't have this method.

Update:

As @kcrisman suggested, maxima_methods() can be used too. This provides a better approach, as it avoids using the underscored method _maxima_().

sage: f(x)=x^3+5*x^2-3*x+1
sage: g(x)=x+1
sage: f.maxima_methods().divide(g)
[x^2 + 4*x - 7, 8]


Perhaps it would be better to define the function as:

def division(dividend, divisor) :
q,r = dividend.maxima_methods().divide(divisor)
print 'quotient: ', q
print 'remainder: ', r


Thanks to @kcrisman for suggesting this!

more

so it isn't relevant to maxima computation system?

( 2013-04-02 17:12:14 +0200 )edit

It is relevant in the sense that it uses the divide method. This method belongs to the coerced object, so my guess is that it uses maxima for that.

( 2013-04-02 18:06:21 +0200 )edit
2

Presumably one could use maxima_methods() for this, then?

( 2013-04-02 18:12:23 +0200 )edit
1

It seems so, I'll update the answer.

( 2013-04-02 18:26:39 +0200 )edit

Hi! Good night! Can you explain me what maxima_methods does in this program?

( 2017-05-23 00:30:06 +0200 )edit