Ask Your Question

Polynomial division command

asked 2013-04-02 08:37:22 -0500

Neda gravatar image

updated 2013-04-02 09:35:08 -0500

kcrisman gravatar image

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]

but could you please explain a little bit about this post? such as what is divided.maxima_() ?

edit retag flag offensive close merge delete


Perhaps [this]( is the post you mention.

fidbc gravatar imagefidbc ( 2013-04-02 10:08:19 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-04-02 10:07:08 -0500

fidbc gravatar image

updated 2013-04-02 11:37:57 -0500

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.


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!

edit flag offensive delete link more


so it isn't relevant to maxima computation system?

Neda gravatar imageNeda ( 2013-04-02 10:12:14 -0500 )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.

fidbc gravatar imagefidbc ( 2013-04-02 11:06:21 -0500 )edit

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

kcrisman gravatar imagekcrisman ( 2013-04-02 11:12:23 -0500 )edit

It seems so, I'll update the answer.

fidbc gravatar imagefidbc ( 2013-04-02 11:26:39 -0500 )edit

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

Mathematic gravatar imageMathematic ( 2017-05-22 17:30:06 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-04-02 08:37:22 -0500

Seen: 3,144 times

Last updated: Apr 02 '13