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.Tue, 16 Nov 2021 16:18:11 +0100Getting the trace polynomialhttps://ask.sagemath.org/question/59766/getting-the-trace-polynomial/Dear all,
I am using sagemath to get the trace polynomial from a given reciprocal polynomial of even degree. The process is described nicely on the documentation. I am not allowed to post a link. See below for a concrete example.
However, the algorithm returns a triple $(Q, R, q)$. For further calculations, I need to take out just the polynomial $Q$. Here is an example
> pol.<x> = PolynomialRing(Rationals())
> sage: u = x^6 +1;
> u1=u.trace_polynomial()
The algorithm returns $u1=(x^3 - 3*x, 1, 1)$ (in my examples, I know that $R=q=1$ always). How can I get the first component of $u1$?
Edit: Simply take $u1[0]$ as suggested below by another user.
How can we resolve this problem? I am sorry if my question is too trivial. Thank you very much!
Best wishes, TungTue, 16 Nov 2021 16:08:43 +0100https://ask.sagemath.org/question/59766/getting-the-trace-polynomial/Answer by rburing for <p>Dear all, </p>
<p>I am using sagemath to get the trace polynomial from a given reciprocal polynomial of even degree. The process is described nicely on the documentation. I am not allowed to post a link. See below for a concrete example. </p>
<p>However, the algorithm returns a triple $(Q, R, q)$. For further calculations, I need to take out just the polynomial $Q$. Here is an example </p>
<blockquote>
<p>pol.<x> = PolynomialRing(Rationals())
sage: u = x^6 +1;
u1=u.trace_polynomial() </p>
</blockquote>
<p>The algorithm returns $u1=(x^3 - 3*x, 1, 1)$ (in my examples, I know that $R=q=1$ always). How can I get the first component of $u1$? </p>
<p>Edit: Simply take $u1[0]$ as suggested below by another user. </p>
<p>How can we resolve this problem? I am sorry if my question is too trivial. Thank you very much! </p>
<p>Best wishes, Tung</p>
https://ask.sagemath.org/question/59766/getting-the-trace-polynomial/?answer=59767#post-id-59767There is a difference between `u` and `u.trace_polynomial()`; the former is a polynomial and the latter is a tuple.
It seems that what you want is just `u.trace_polynomial()[0]`.Tue, 16 Nov 2021 16:14:25 +0100https://ask.sagemath.org/question/59766/getting-the-trace-polynomial/?answer=59767#post-id-59767Comment by tungnt for <p>There is a difference between <code>u</code> and <code>u.trace_polynomial()</code>; the former is a polynomial and the latter is a tuple.</p>
<p>It seems that what you want is just <code>u.trace_polynomial()[0]</code>.</p>
https://ask.sagemath.org/question/59766/getting-the-trace-polynomial/?comment=59768#post-id-59768You are right. I am so sorry for this trivial mistake. It works!
To the moderator: if you feel that my question is too trivial, please delete it. I am sorry about this.Tue, 16 Nov 2021 16:18:11 +0100https://ask.sagemath.org/question/59766/getting-the-trace-polynomial/?comment=59768#post-id-59768