Ask Your Question
1

How to construct a polynomial from string?

asked 2012-07-09 19:47:25 -0600

skypluto gravatar image

Hi,

I can run the following (putting in a .sage file) successfully.

R.<x> = QQ[]

f = x^3 - x^2 + x -1

p = x - 2

print f.quo_rem(p)

But how about I have a string 'x^3 - x^2 + x -1', how can I construct f.

f = SR('x^3 - x^2 + x -1') is not working as there is no member function quo_rem for Expression.

Thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2012-07-09 20:07:22 -0600

achrzesz gravatar image
sage: R.<x> = QQ[]
sage: f = R('x^3 - x^2 + x -1') 
sage: f.quo_rem(x-2)
(x^2 + x + 3, 5)
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: 2012-07-09 19:47:25 -0600

Seen: 517 times

Last updated: Jul 09 '12