divide polynomials

181 views
Skip to first unread message

ma...@mendelu.cz

unread,
Dec 17, 2009, 4:48:30 AM12/17/09
to sage-support
Dear support, maybe I missed something, but I am not able to find
command for dividing polynomials (to get the quotient and the
remainder). Can you help me? Many thanks.

Robert

Simon King

unread,
Dec 17, 2009, 5:03:03 AM12/17/09
to sage-support
Hi Robert!

sage: R.<t> = QQ[]
sage: p = R.random_element()
sage: q = R.random_element()
sage: p
-t^2 - 1/2*t + 1/2
sage: q
-t - 4/3
sage: p.quo_rem(q)
(t - 5/6, -11/18)


Best regards,
Simon

ma...@mendelu.cz

unread,
Dec 17, 2009, 5:29:43 AM12/17/09
to sage-support
Many thanks. Robert.

Pablo Angulo

unread,
Dec 17, 2009, 12:18:59 PM12/17/09
to sage-support
And also:

sage: p//q
t - 5/6

sage: p%q
-11/18

ma...@mendelu.cz

unread,
Dec 17, 2009, 1:29:33 PM12/17/09
to sage-support
Thanks! Is there faster way how to tell Sage that we want to divide
polynomials than these commands? I mean, if the third line can be
omitted.

p=x^2+x+5
q=x-4
R.<x>=QQ[]
R(p).quo_rem(q)

Robert.

William Stein

unread,
Dec 17, 2009, 4:21:38 PM12/17/09
to sage-support
On Thu, Dec 17, 2009 at 10:29 AM, ma...@mendelu.cz <ma...@mendelu.cz> wrote:
> Thanks! Is there faster way how to tell Sage that we want to divide
> polynomials than these commands? I mean, if the third line can be
> omitted.
>
> p=x^2+x+5
> q=x-4
> R.<x>=QQ[]
> R(p).quo_rem(q)


No. But you have the order a little wrong (though what you write
will work). It should be:

R.<x> = QQ[] # or x = polygen(QQ)
p = x^2 + x + 5
q = x - 4
p.quo_rem(q)

William

Reply all
Reply to author
Forward
0 new messages