Ask Your Question

Evaluate a list

asked 2016-02-11 20:57:56 +0200

Dianbin Bao gravatar image

updated 2024-04-14 08:12:59 +0200

FrédéricC gravatar image


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 21:31:10 +0200

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 22:35:01 +0200 )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 20:57:56 +0200

Seen: 703 times

Last updated: Feb 11 '16