ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 12 Mar 2019 06:23:14 -0500How to compute the sums of squares of elements of a quotient ring?http://ask.sagemath.org/question/45767/how-to-compute-the-sums-of-squares-of-elements-of-a-quotient-ring/ Hi,
I'm new to Sage, and I would like to be able to test, given some $q$, whether $$\sum_{p(t) \in \mathbb{F}_{q}[t]/(f)}^{}{p^2(t)}=k \bmod (f)$$
for some fixed $f \in \mathbb{F}_q [t]$ and $k \in \mathbb{F}_q$.
I can get as far as (for $q=3$ and $f=x^2+1$):
sage: R = PolynomialRing(GF(3),'x'); x = R.gen()
sage: S = R.quotient(x^2 + 1)
But I'm not sure how to sum over all the elements of the quotient ring, let alone their squares.
Any hints?
Mon, 11 Mar 2019 21:07:03 -0500http://ask.sagemath.org/question/45767/how-to-compute-the-sums-of-squares-of-elements-of-a-quotient-ring/Answer by rburing for <p>Hi,</p>
<p>I'm new to Sage, and I would like to be able to test, given some $q$, whether $$\sum_{p(t) \in \mathbb{F}_{q}[t]/(f)}^{}{p^2(t)}=k \bmod (f)$$
for some fixed $f \in \mathbb{F}_q [t]$ and $k \in \mathbb{F}_q$.</p>
<p>I can get as far as (for $q=3$ and $f=x^2+1$):</p>
<pre><code>sage: R = PolynomialRing(GF(3),'x'); x = R.gen()
sage: S = R.quotient(x^2 + 1)
</code></pre>
<p>But I'm not sure how to sum over all the elements of the quotient ring, let alone their squares.</p>
<p>Any hints?</p>
http://ask.sagemath.org/question/45767/how-to-compute-the-sums-of-squares-of-elements-of-a-quotient-ring/?answer=45768#post-id-45768You can do it like this (also simplifying the notation a bit):
sage: R.<x> = PolynomialRing(GF(3))
sage: S.<i> = R.quotient(x^2 + 1)
sage: sum(p^2 for p in S)
0
We can explain the result (for this choice of $f$) as follows: $p(i) = a+bi$ implies $p(i)^2 = a^2 - b^2 + 2abi$ and the sum runs over all $a$ and $b$, so the "real part" of the sum is $$\sum_{a,b} a^2 - b^2 = \sum_a a^2 - \sum_b b^2 = 0,$$ and the "imaginary part" is $$\sum_{a,b} 2ab = \sum_{a,b} ab + \sum_{a,b} ab = \sum_{a,b} ab + \sum_{a,b} (-a)b = \sum_{a,b} ab - ab = 0.$$Tue, 12 Mar 2019 04:11:26 -0500http://ask.sagemath.org/question/45767/how-to-compute-the-sums-of-squares-of-elements-of-a-quotient-ring/?answer=45768#post-id-45768Comment by Llew for <p>You can do it like this (also simplifying the notation a bit):</p>
<pre><code>sage: R.<x> = PolynomialRing(GF(3))
sage: S.<i> = R.quotient(x^2 + 1)
sage: sum(p^2 for p in S)
0
</code></pre>
<p>We can explain the result (for this choice of $f$) as follows: $p(i) = a+bi$ implies $p(i)^2 = a^2 - b^2 + 2abi$ and the sum runs over all $a$ and $b$, so the "real part" of the sum is $$\sum_{a,b} a^2 - b^2 = \sum_a a^2 - \sum_b b^2 = 0,$$ and the "imaginary part" is $$\sum_{a,b} 2ab = \sum_{a,b} ab + \sum_{a,b} ab = \sum_{a,b} ab + \sum_{a,b} (-a)b = \sum_{a,b} ab - ab = 0.$$</p>
http://ask.sagemath.org/question/45767/how-to-compute-the-sums-of-squares-of-elements-of-a-quotient-ring/?comment=45770#post-id-45770Thank you, that is very helpful.Tue, 12 Mar 2019 06:23:14 -0500http://ask.sagemath.org/question/45767/how-to-compute-the-sums-of-squares-of-elements-of-a-quotient-ring/?comment=45770#post-id-45770