Skip to content

Commit 5b78749

Browse files
committed
fix some details in doc of charpoly_frobenius
1 parent 54cd6fe commit 5b78749

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

src/sage/schemes/cyclic_covers/charpoly_frobenius.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
r"""
2-
32
Computation of the Frobenius polynomial using Newton's identities
4-
53
"""
6-
7-
84
# *****************************************************************************
95
# Copyright (C) 2018 Edgar Costa <[email protected]>
106
# Distributed under the terms of the GNU General Public License (GPL)
117
# https://www.gnu.org/licenses/
128
# *****************************************************************************
13-
149
from sage.rings.integer_ring import ZZ
1510
from sage.functions.log import log
1611

@@ -23,15 +18,15 @@ def charpoly_frobenius(frob_matrix, charpoly_prec, p, weight, a=1, known_factor=
2318
2419
- ``frob_matrix`` -- a matrix representing the Frobenius matrix up to some precision
2520
26-
- ``charpoly_prec`` -- a vector ai, such that, `frob_matrix.change_ring(ZZ).charpoly()[i]`
27-
will be correct mod `p^ai`, this can be easily deduced from the Hodge numbers and
28-
knowing the q-adic precision of ``frob_matrix``
21+
- ``charpoly_prec`` -- a vector ai, such that, ``frob_matrix.change_ring(ZZ).charpoly()[i]``
22+
will be correct mod `p^ai`, this can be easily deduced from the
23+
Hodge numbers and knowing the q-adic precision of ``frob_matrix``
2924
3025
- ``p`` -- prime `p`
3126
3227
- ``weight`` -- weight of the motive
3328
34-
- ``a`` -- `q = q^a`
29+
- ``a`` -- `p = q^a`
3530
3631
- ``known_factor`` -- the list of coefficients of the known factor
3732
@@ -195,14 +190,12 @@ def charpoly_frobenius(frob_matrix, charpoly_prec, p, weight, a=1, known_factor=
195190
sage: F+= F.base_ring()(0).add_bigoh(6)*ones_matrix(*F.dimensions())
196191
sage: charpoly_frobenius(F, [6, 5, 4, 4], 17, 2)
197192
[-4913, -221, 13, 1]
198-
199-
200193
"""
201194
assert known_factor[-1] == 1
202195
try:
203196
cp = frob_matrix.change_ring(ZZ).charpoly().list()
204197
except ValueError:
205-
# the given matrix wasn't integral
198+
# the given matrix was not integral
206199
cp = frob_matrix.charpoly().change_ring(ZZ).list()
207200
assert len(charpoly_prec) == len(cp) - (len(known_factor) - 1)
208201
assert cp[-1] == 1
@@ -216,7 +209,7 @@ def charpoly_frobenius(frob_matrix, charpoly_prec, p, weight, a=1, known_factor=
216209

217210
# figure out the sign
218211
# i.e., if it is a reciprocal or an antireciprocal polynomial
219-
if weight % 2 == 1:
212+
if weight % 2:
220213
# for odd weight the sign is always 1
221214
# it's the charpoly of a USp matrix
222215
# and charpoly of a symplectic matrix is reciprocal
@@ -227,7 +220,7 @@ def charpoly_frobenius(frob_matrix, charpoly_prec, p, weight, a=1, known_factor=
227220
raise NotImplementedError()
228221
# we compare ith coefficient and (degree - i)th coefficient to deduce the sign
229222
# note, if degree is even, the middle coefficient will not help us determine the sign
230-
for i in range((degree + 1)//2):
223+
for i in range((degree + 1) // 2):
231224
# Note: degree*weight is even
232225
p_power = p**min(
233226
charpoly_prec[i],
@@ -248,19 +241,21 @@ def charpoly_frobenius(frob_matrix, charpoly_prec, p, weight, a=1, known_factor=
248241
# note, this includes the middle coefficient if degree is even
249242
halfdegree = degree // 2 + 1
250243

251-
cp[0] = sign * p**((a * degree * weight) // 2) # Note: degree*weight is even
244+
cp[0] = sign * p**((a * degree * weight) // 2)
245+
# Note: degree*weight is even
246+
252247
# calculate the i-th power sum of the roots and correct cp along the way
253248
e = cp[-halfdegree:]
254249
e.reverse()
255250
for k in range(halfdegree):
256-
if k % 2 != 0:
251+
if k % 2:
257252
e[k] = -e[k] % mod[degree - k]
258253
# e[k] = cp[degree - k] if (k%2 ==0) else -cp[degree - k]
259254
if k > 0:
260255
# verify if p^charpoly_prec[degree - k] > 2*degree/k * q^(w*k/2)
261256
assert (
262-
log(k) / log(p) + charpoly_prec[degree - k]
263-
> log(2 * degree) / log(p) + a * 0.5 * weight * k
257+
log(k, p) + charpoly_prec[degree - k]
258+
> log(2 * degree, p) + a * 0.5 * weight * k
264259
), (
265260
"log(k)/log(p) + charpoly_prec[degree - k] <= log(2*degree)/log(p) + a*0.5*weight*k, k = %d"
266261
% k
@@ -271,7 +266,7 @@ def charpoly_frobenius(frob_matrix, charpoly_prec, p, weight, a=1, known_factor=
271266
if len(fix_e) < halfdegree:
272267
fix_e.extend([0] * (halfdegree - len(fix_e)))
273268
for i in range(halfdegree):
274-
if i % 2 != 0:
269+
if i % 2:
275270
fix_e[i] *= -1
276271

277272
# e[k] = \sum x_{i_1} x_{i_2} ... x_{i_k} # where x_* are eigenvalues
@@ -280,7 +275,9 @@ def charpoly_frobenius(frob_matrix, charpoly_prec, p, weight, a=1, known_factor=
280275
# s[k] = \sum x_i ^k for k>0
281276
s = [None] * (halfdegree)
282277
res = [None] * len(charpoly_prec)
283-
res[0] = sign * p**((a * degree * weight) // 2) # Note: degree*weight is even
278+
res[0] = sign * p**((a * degree * weight) // 2)
279+
# Note: degree*weight is even
280+
284281
res[-1] = 1
285282
e[1] -= fix_e[1]
286283
e[1] = e[1] % mod[degree - 1]
@@ -306,8 +303,9 @@ def charpoly_frobenius(frob_matrix, charpoly_prec, p, weight, a=1, known_factor=
306303
# (-1)^(k-1) s[k] - S = k*e[k]
307304
e[k] = (-S + (-1)**(k - 1) * s[k]) // k
308305
assert (-S + (-1)**(k - 1) * s[k]) % k == 0
309-
res[degree - k] = e[k] if k % 2 == 0 else -e[k]
306+
res[degree - k] = e[k] if not k % 2 else -e[k]
310307
# Note: degree*weight is even
308+
311309
res[k] = sign * res[degree - k] * p**((a * (degree - 2 * k) * weight) // 2)
312310
# fix e[k + 1]
313311
if k + 1 < halfdegree:

0 commit comments

Comments
 (0)