Ask Your Question
0

Evaluate a list

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

Dianbin Bao gravatar image

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

FrédéricC gravatar image

Hi,

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
1

answered 2016-02-11 21:31:10 +0100

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)
-1

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)
-1
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

Comments

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

Dianbin Bao gravatar imageDianbin Bao ( 2016-02-11 22:35:01 +0100 )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

Stats

Asked: 2016-02-11 20:57:56 +0100

Seen: 866 times

Last updated: Feb 11 '16