First time here? Check out the FAQ!

Ask Your Question
2

How to construct a polynomial from string?

asked 12 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
6

answered 12 years ago

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)
Preview: (hide)
link

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: 12 years ago

Seen: 1,865 times

Last updated: Jul 10 '12