Ask Your Question

Creating a polynomial from a string with symbolic constants

asked 2022-06-29 18:32:42 +0200

Below is some code that does the following. First, define R to be the univariate polynomial ring Q_2[x], and let f(x) be the polynomial x^2 - 2 in this ring. Then let K be the totally ramified quadratic extension defined by this polynomial, and call its generator a. Let S be the polynomial ring K[y]. Then I would like to define a polynomial y + a in S. This works find if I write f1 = S(y+a), but it fails if I try f2 = S('y + a'). However, I need to be able to define my polynomial from a string as in the f2 case. Can anyone help?

R.<x> = Qp(2,100)[]
f = R(x^2 - 2)
K.<a> = Qp(2,100).ext(f)
S.<y> = K[]

# The next line works
f1 = S(y + a)
# The next one throws an error
f2 = S('y + a')
edit retag flag offensive close merge delete


Why do you need to define a polynomial from a string? Sounds like it could be an XY problem.

rburing gravatar imagerburing ( 2022-07-02 08:13:15 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-06-29 21:23:42 +0200

slelievre gravatar image

There might be room for improvement there.

Here are two possibilities to work around this limitation.

sage: f2 = S(eval('y + a'))
sage: f2 = eval('S(y + a)')
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

1 follower


Asked: 2022-06-29 18:32:42 +0200

Seen: 144 times

Last updated: Jun 29 '22