Ask Your Question
0

Evaluate a list

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

Dianbin Bao gravatar image

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

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 14:31:10 -0600

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 15:35:01 -0600 )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 13:57:56 -0600

Seen: 117 times

Last updated: Feb 11 '16