Ask Your Question
0

Can't do simple algebraic division

asked 2020-08-01 05:01:46 +0200

cybervigilante gravatar image

updated 2020-08-01 05:41:50 +0200

slelievre gravatar image

Why can't I do a simple division with Sage? All I get out is what I put in. I can do this by hand easily but no matter what method or option I try I get the same answer.

In: (3*x^3+x^2-3*x+5)/(x+1)
Out: (3*x^3 + x^2 - 3*x + 5)/(x + 1)
edit retag flag offensive close merge delete

Comments

Please indicate what answer you are expecting. Especially since you can do this by hand easily!

Then we might know how to help you attain the same answer with Sage.

Regarding "no matter what method or option I try", please list the methods and options you tried.

Then we can comment on why any particular method or option should have behaved the way it did or any other way. Maybe we can fix some bugs. But we need to see exactly what is going wrong.

slelievre gravatar imageslelievre ( 2020-08-01 05:45:26 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-08-01 07:48:39 +0200

slelievre gravatar image

Try using polynomials a polynomial ring.

Then you can define

  • two polynomials in it,
  • the rational fraction obtained by dividing one by the other
  • the quotient and remainder

Define a polynomial ring:

sage: R.<x> = QQ[]

Or just a polynomial ring generator:

sage: x = polygen(QQ)

Define two polynomials:

sage: a = 3*x^3 + x^2 - 3*x + 5
sage: b = x + 1

Divide:

sage: c = a / b
sage: c
3*x^3 + x^2 - 3*x + 5)/(x + 1)

Quotient and remainder

sage: q = a // b
sage: q
3*x^2 - 2*x - 1

sage: r = a % b
sage: r
6

Both at once

sage: q, r = a.quo_rem(b)
sage: q
3*x^2 - 2*x - 1
sage: r
6

Check:

sage: q + r/b
(3*x^3 + x^2 - 3*x + 5)/(x + 1)
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2020-08-01 05:01:46 +0200

Seen: 202 times

Last updated: Aug 01 '20