ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 23 Mar 2019 12:26:52 +0100Evaluating polynomials in Z[x] at roots of unity.https://ask.sagemath.org/question/45880/evaluating-polynomials-in-zx-at-roots-of-unity/Suppose that I have a polynomial $p(x)$ with integer coeffcients, then I can easily evaluate this at some integer to get an exact answer. That is, I can write something like
sage: p=1+x+2*x^2+x^3+x^4
sage: p(2)
35
But If I instead want to evaluate this polynomial at a root of unity (I take $w$ to be a primitive $5$:th root of unity in the example below but any root of unity would do), then I may write say
sage: w = e^(2*pi*i/5)
sage: p(w)
1/256*(sqrt(5) + I*sqrt(2*sqrt(5) + 10) - 1)^4 + 1/64*(sqrt(5) + I*sqrt(2*sqrt(5) + 10) - 1)^3 + 1/8*(sqrt(5) + I*sqrt(2*sqrt(5) + 10) - 1)^2 + 1/4*sqrt(5) + 1/4*I*sqrt(2*sqrt(5) + 10) + 3/4
Which is a correct answer but written in a very complicated form. Alternatively, I can write
sage: K.<z> = CyclotomicField(5)
sage: w=CC(z)
sage: p(w)
-0.809016994374947 + 0.587785252292473*I
which is an approximation of the correct answers. In the above case, we actually have $p(w)=w^2$ and I am wondering if there is an easy way to always obtain such an answer. For a general $p(x)$ with integer coefficients and $w$ that is a primitive $n$:th root of unity, we can write $p(w)$ on the form
$$a_0+a_1 w + a_2 w^2 + \dots +a_{n-1} w^{n-1}$$
where the $a_i$:s are integers. Is there a good way to get the $p(w)$ on this form in Sage?joakim_uhlinSat, 23 Mar 2019 12:26:52 +0100https://ask.sagemath.org/question/45880/nth root of huge numberhttps://ask.sagemath.org/question/35102/nth-root-of-huge-number/
I have been reading for the last hour about different ways to take an nth root in sage. I am having trouble finding a way to do so for a number such as
383359376317228026832765614031101780857214373741934853796883469684751393959423303934031779306976105234618634914722122231966050161090557311139688754390702005669975825514220776140658553598335180339644221202109745240693646681489614040361698983885974381266138822986136754230956173498395067036601233601299698337833849969027885834924082799260330843401454066113756946449729494314541583444719025620597701816509274146453
Any help would be much appreciated. I have tried ^(1/n) and pow and a number of others.questioner14Mon, 10 Oct 2016 04:05:01 +0200https://ask.sagemath.org/question/35102/