Ask Your Question
2

How to construct a polynomial from string?

asked 2012-07-10 02:47:25 +0200

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
6

answered 2012-07-10 03:07:22 +0200

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-10 02:47:25 +0200

Seen: 1,243 times

Last updated: Jul 10 '12