Exemple #1
0
def _torsion_poly(ell, P=None):
    """
    Computes the ell-th gauss period. If `P` is given, it must be a
    polynomial ring into which the result is coerced.

    This is my favourite equality:
    
    sage: all(_torsion_poly(n)(I) == I^n*lucas_number2(n,1,-1) for n in range(1,10))
    True
    """
    if P is None:
        P, R, = PolynomialRing(ZZ, 'x'), ZZ, 
    elif P.characteristic() == 0:
        R = ZZ
    else:
        R = Zp(P.characteristic(), prec=1, type='capped-rel')
    
    t = [1, 0]
    for k in range(1, ell/2 + 1):
        m = R(ell - 2*k + 2) * R(ell - 2*k + 1) / (R(ell - k) * R(k))
        t.append(-t[-2] * m)
        t.append(0)

    return P(list(reversed(t))).shift(ell % 2 - 1)
Exemple #2
0
def _torsion_poly(ell, P=None):
    """
    Computes the ell-th gauss period. If `P` is given, it must be a
    polynomial ring into which te result is coerced.

    This is my favourite equality:
    
    sage: all(_torsion_poly(n)(I) == I^n*lucas_number2(n,1,-1) for n in range(1,10))
    True
    """
    if P is None:
        P, R, = PolynomialRing(ZZ, 'x'), ZZ, 
    elif P.characteristic() == 0:
        R = ZZ
    else:
        R = Zp(P.characteristic(), prec=1, type='capped-rel')
    
    t = [1, 0]
    for k in range(1, ell/2 + 1):
        m = R(ell - 2*k + 2) * R(ell - 2*k + 1) / (R(ell - k) * R(k))
        t.append(-t[-2] * m)
        t.append(0)

    return P(list(reversed(t))).shift(ell % 2 - 1)