Ask Your Question

Evaluate a list

asked 2016-02-11 13:57:56 -0500

Dianbin Bao gravatar image

updated 2016-02-11 15:28:22 -0500


Suppose for example E =[x,x^2,x+1] is a list of elements in ZZ[x]. Let K be a number field defined in Sage

K.<a> = NumberField(f(x))

for some irreducible polynomial $f(x)$. Then how can one evaluate the list E by setting $x=a$ and $x=\sigma(a)$ (conjugate of a) in Sage?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-02-11 14:31:10 -0500

tmonteil gravatar image

You can use the subs method of polynomials:

sage: x = polygen(ZZ)
sage: K.<a>= NumberField(x^2+1)
sage: (x^2).subs(x=a)

Now, if you want to apply it to all elements of a list E, you can use Python's list comprehension:

sage: [p.subs(x=a) for p in E]
[a, -1, a + 1]

Or, for the conjugate:

sage: [p.subs(x=a.conjugate()) for p in E]
[-a, -1, -a + 1]

Note that in the univariate case, you can directly call the polynomial:

sage: (x^2)(a)
sage: [p(a) for p in E]
[a, -1, a + 1]
sage: [p(a.conjugate()) for p in E]
[-a, -1, -a + 1]
edit flag offensive delete link more


Thanks very much, T,monteil. You save me the day!

Dianbin Bao gravatar imageDianbin Bao ( 2016-02-11 15:35:01 -0500 )edit

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: 2016-02-11 13:57:56 -0500

Seen: 115 times

Last updated: Feb 11 '16