Divisors

Initialize self. See help(type(self)) for accurate signature.

class darmonpoints.divisors.Divisors(base)[source]

Bases: Parent, CachedRepresentation

Element

alias of DivisorsElement

base()[source]
class darmonpoints.divisors.DivisorsElement(parent, data, ptdata=None)[source]

Bases: ModuleElement

A Divisor is given by a list of pairs (P,nP), where P is a point, and nP is an integer.

TESTS:

sage: from darmonpoints.divisors import Divisors
sage: Cp.<g> = Qq(5^3,20)
sage: Div = Divisors(Cp)
sage: D1 = Div(g+3)
sage: D2 = Div(2*g+1)
sage: D = D1 + D2
sage: print(-D)
Divisor of degree -2
sage: print(2*D1 + 5*D2)
Divisor of degree 7
apply_map(f)[source]
as_list_of_differences()[source]
degree()[source]

EXAMPLES:

sage: class Foo:
....:     def __init__(self, x):
....:         self._x = x
....:     @cached_method
....:     def f(self):
....:         return self._x^2
sage: a = Foo(2)
sage: print(a.f.cache)
None
sage: a.f()
4
sage: a.f.cache
4
gcd()[source]
intersects(right)[source]
is_zero()[source]
left_act_by_matrix(g)[source]
pair_with(D)[source]
rational_function(as_map=False, z=None)[source]
restrict(condition)[source]
scale_by(a)[source]
size()[source]

Returns the size of self, defined as the sum of the absolute values of the coefficients.

support()[source]
value()[source]

Mixed extensions

Initialize self. See help(type(self)) for accurate signature.

class darmonpoints.mixed_extension.QuadExt(base, polynomial, category=None)

Bases: UniqueRepresentation, Field

A quadratic extension of a p-adic field.

EXAMPLES:

sage: from darmonpoints.mixed_extension import *
sage: p = 7
sage: K0.<z> = Qq(p**2,20)
sage: K = QuadExt(K0, p)
sage: print(K(3) + K(5))
1 + 7 + O(7^20) + ( 0 )*pi
sage: print(K(3) - K(5))
5 + 6*7 + 6*7^2 + 6*7^3 + 6*7^4 + 6*7^5 + 6*7^6 + 6*7^7 + 6*7^8 + 6*7^9 + 6*7^10 + 6*7^11 + 6*7^12 + 6*7^13 + 6*7^14 + 6*7^15 + 6*7^16 + 6*7^17 + 6*7^18 + 6*7^19 + O(7^20) + ( 0 )*pi
sage: print(K(3) * K(5))
1 + 2*7 + O(7^20) + ( O(7^20) )*pi
sage: print(K.gen())
0 + ( 1 + O(7^20) )*pi
sage: print(K.gen()**2)
7 + O(7^21) + ( O(7^20) )*pi
sage: print((K(1) + K.gen())**2)
1 + 7 + O(7^20) + ( 2 + O(7^20) )*pi
sage: print(K(3)/K(2))
5 + 3*7 + 3*7^2 + 3*7^3 + 3*7^4 + 3*7^5 + 3*7^6 + 3*7^7 + 3*7^8 + 3*7^9 + 3*7^10 + 3*7^11 + 3*7^12 + 3*7^13 + 3*7^14 + 3*7^15 + 3*7^16 + 3*7^17 + 3*7^18 + 3*7^19 + O(7^20) + ( 0 )*pi
sage: print(K(3,2)/K(5,6))
2 + 5*7 + 4*7^2 + 2*7^4 + 3*7^5 + 4*7^6 + 3*7^7 + 5*7^8 + 7^9 + 4*7^10 + 3*7^11 + 3*7^12 + 4*7^13 + 5*7^14 + 2*7^15 + 5*7^17 + 6*7^18 + 2*7^19 + O(7^20) + ( 5 + 4*7^2 + 3*7^4 + 4*7^5 + 7^6 + 7^7 + 3*7^8 + 3*7^9 + 4*7^11 + 5*7^12 + 5*7^13 + 5*7^14 + 5*7^16 + 3*7^17 + 4*7^18 + O(7^20) )*pi
sage: print(K0(2) * K.gen())
0 + ( 2 + O(7^20) )*pi
sage: print(2 * K.gen())
0 + ( 2 + O(7^20) )*pi

sage: x = QQ['x'].gen()
sage: f = x^2 - 3*x + 1
sage: print(f(K.gen()))
1 + 7 + O(7^20) + ( 4 + 6*7 + 6*7^2 + 6*7^3 + 6*7^4 + 6*7^5 + 6*7^6 + 6*7^7 + 6*7^8 + 6*7^9 + 6*7^10 + 6*7^11 + 6*7^12 + 6*7^13 + 6*7^14 + 6*7^15 + 6*7^16 + 6*7^17 + 6*7^18 + 6*7^19 + O(7^20) )*pi
sage: print(K(K.base_ring()(0)))
0 + ( 0 )*pi
Element

alias of QuadExtElement

absolute_degree()
base_ring()
characteristic()
gen()
is_finite()
polynomial()
precision_cap()
prime()
ramification_index()
random_element()
relative_degree()
residue_class_degree()
some_elements()
uniformizer()
unramified_generator()
class darmonpoints.mixed_extension.QuadExtElement(parent, x, y=None, check=True)

Bases: FieldElement

list()
norm_relative()
ordp(p=None)
sqrt(return_all=False)
trace_absolute()
trace_relative()
valuation(p=None)
darmonpoints.mixed_extension.get_word_rep_fast(self, delta, Pold=None)

Sparse matrix calculations

Initialize self. See help(type(self)) for accurate signature.

darmonpoints.sparse.compute_lift_sparse_cy(big_system, indeps, edge_to_eqs)

Utility package

Initialize self. See help(type(self)) for accurate signature.

class darmonpoints.util.Bunch(**kwds)[source]

Bases: object

get(name, default=None)[source]
update(**v)[source]
darmonpoints.util.FGP_V(x)[source]
darmonpoints.util.FGP_W(x)[source]
darmonpoints.util.JtoP(H, MR, p=None)[source]
darmonpoints.util.M2Z(v)[source]
darmonpoints.util.act_H3(g, w)[source]
darmonpoints.util.act_flt(g, x)[source]
darmonpoints.util.act_flt_in_disc(g, x, P)[source]
darmonpoints.util.affine_transformation(x1p, x2p, x3p)[source]
darmonpoints.util.cantor_diagonal(iter1, iter2)[source]
darmonpoints.util.config_section_map(config, section)[source]
darmonpoints.util.conjugate_quaternion_over_base(q)[source]
darmonpoints.util.covolume(F, D, M=1, prec=None, zeta=None)[source]
darmonpoints.util.direct_sum_of_maps(v)[source]
darmonpoints.util.direct_sum_of_modules(v)[source]
darmonpoints.util.discover_equation(qE, emb, conductor, prec, field=None, check_conductor=True, height_threshold=0.85)[source]
darmonpoints.util.enumerate_words(v, n=None, max_length=-1)[source]
darmonpoints.util.field_element_pari_to_sage(w, Fp, elt)[source]
darmonpoints.util.find_center(p, level, t1, t2)[source]

This function computes the center between two points in Cp

darmonpoints.util.find_containing_affinoid(p, z, level=1)[source]

Returns the vertex corresponding to the affinoid in the p-adic upper half plane that a given (unramified!) point reduces to.

INPUT:

  • z - an element of an unramified extension of QQ_p that is not contained in QQ_p.

OUTPUT:

A 2x2 integer matrix representing the affinoid.

sage: K.<a> = Qq(5^2,20) sage: from darmonpoints.util import find_containing_affinoid sage: find_containing_affinoid(5,a) [1 0] [0 1] sage: z = 5*a+3 sage: v = find_containing_affinoid(5,z).inverse(); v [ 1/5 -3/5] [ 0 1]

Note that the translate of z belongs to the standard affinoid. That is, it is a p-adic unit and its reduction modulo p is not in FF_p:

sage: a,b,c,d = v.list()
sage: gz = (a*z+b)/(c*z+d); gz
a + O(5^19)
sage: gz.valuation() == 0
True
darmonpoints.util.find_the_unit_of(F, K)[source]
darmonpoints.util.fwrite(string, outfile, newline=True)[source]
darmonpoints.util.get_C_and_C2(E, qEpows, R, prec)[source]
darmonpoints.util.get_c4_and_c6(qE, prec)[source]
darmonpoints.util.get_heegner_params(p, E, beta)[source]
darmonpoints.util.get_j_invariant(qE, prec)[source]
darmonpoints.util.getcoords(E, u, prec=None, R=None, qE=None, qEpows=None, C=None)[source]
darmonpoints.util.height_polynomial(x, base=10)[source]
darmonpoints.util.hensel_lift(f, x0, max_iters=None)[source]
darmonpoints.util.imag_part(a)[source]
darmonpoints.util.is_in_Gamma0loc(A, det_condition=True, p=None)[source]

Whether the matrix A has all entries Zp-integral, and is upper-triangular mod p.

darmonpoints.util.is_in_Gamma_1(mat, N, p=None, determinant_condition=True)[source]
darmonpoints.util.is_in_principal_affinoid(p, z)[source]
darmonpoints.util.is_infinity(x)[source]
darmonpoints.util.is_smooth(x, B)[source]
darmonpoints.util.lift_padic_splitting(a, b, II0, JJ0, p, prec)[source]
darmonpoints.util.magma_F_elt_to_sage(F_sage, x, magma)[source]
darmonpoints.util.magma_F_ideal_to_sage(F_sage, x, magma)[source]
darmonpoints.util.magma_integral_quaternion_to_sage(B_sage, O_magma, F_magma, x, magma)[source]
darmonpoints.util.magma_quaternion_to_sage(B_sage, x, magma)[source]
darmonpoints.util.module_generators()[source]

Create a cached version of a function, which only recomputes values it hasn’t already computed. A custom name can be provided by an optional argument “name”.

If f is a function, do either g = CachedFunction(f) to make a cached version of f, or put @CachedFunction right before the definition of f (i.e., use Python decorators):

@CachedFunction
def f(...):
    ....

The inputs to the function must be hashable or they must define sage.structure.sage_object.SageObject._cache_key().

TESTS:

sage: # needs sage.combinat
sage: g = CachedFunction(number_of_partitions)
sage: g.__name__
'number_of_partitions'
sage: 'partitions' in sage.misc.sageinspect.sage_getdoc(g)
True
sage: g(5)                                                                  # needs sage.libs.flint
7
sage: g.cache                                                               # needs sage.libs.flint
{((5, 'default'), ()): 7}

sage: def f(t=1): print(t)
sage: h = CachedFunction(f)
sage: w = walltime()
sage: h(); h(1); h(t=1)
1
sage: walltime(w) < 2
True

By default, the contents of the cache are not pickled:

sage: @cached_function
....: def f(n): return None
sage: import __main__
sage: __main__.f = f
sage: for i in range(100): f(i)
sage: len(f.cache)
100

sage: s = dumps(f)
sage: f.clear_cache()
sage: f = loads(s)
sage: len(f.cache)
0

If do_pickle is set, then the cache is pickled:

sage: @cached_function(do_pickle=True)
....: def f(n): return None
sage: __main__.f = f
sage: for i in range(100): f(i)
sage: len(f.cache)
100

sage: s = dumps(f)
sage: f.clear_cache()
sage: f = loads(s)
sage: len(f.cache)
100
darmonpoints.util.module_generators_new()[source]

Create a cached version of a function, which only recomputes values it hasn’t already computed. A custom name can be provided by an optional argument “name”.

If f is a function, do either g = CachedFunction(f) to make a cached version of f, or put @CachedFunction right before the definition of f (i.e., use Python decorators):

@CachedFunction
def f(...):
    ....

The inputs to the function must be hashable or they must define sage.structure.sage_object.SageObject._cache_key().

TESTS:

sage: # needs sage.combinat
sage: g = CachedFunction(number_of_partitions)
sage: g.__name__
'number_of_partitions'
sage: 'partitions' in sage.misc.sageinspect.sage_getdoc(g)
True
sage: g(5)                                                                  # needs sage.libs.flint
7
sage: g.cache                                                               # needs sage.libs.flint
{((5, 'default'), ()): 7}

sage: def f(t=1): print(t)
sage: h = CachedFunction(f)
sage: w = walltime()
sage: h(); h(1); h(t=1)
1
sage: walltime(w) < 2
True

By default, the contents of the cache are not pickled:

sage: @cached_function
....: def f(n): return None
sage: import __main__
sage: __main__.f = f
sage: for i in range(100): f(i)
sage: len(f.cache)
100

sage: s = dumps(f)
sage: f.clear_cache()
sage: f = loads(s)
sage: len(f.cache)
0

If do_pickle is set, then the cache is pickled:

sage: @cached_function(do_pickle=True)
....: def f(n): return None
sage: __main__.f = f
sage: for i in range(100): f(i)
sage: len(f.cache)
100

sage: s = dumps(f)
sage: f.clear_cache()
sage: f = loads(s)
sage: len(f.cache)
100
darmonpoints.util.multiply_out(word, genlist, z=1)[source]
darmonpoints.util.muted(func)[source]
darmonpoints.util.our_algdep(z, degree, prec=None)[source]
darmonpoints.util.our_cuberoot(xx, K=None, return_all=False)[source]
darmonpoints.util.our_lindep(V, prec=None, base=None)[source]
darmonpoints.util.our_nroot(xx, n, K=None, return_all=False)[source]
darmonpoints.util.our_sqrt(xx, K=None, return_all=False)[source]
darmonpoints.util.pari_ordmax_basis_to_sage(w, Ap)[source]
darmonpoints.util.period_from_coords(R, E, P, prec=20, K_to_Cp=None)[source]

Given a point P in the formal group of the elliptic curve E with split multiplicative reduction, this produces an element u in QQ_p^{times} mapped to the point P by the Tate parametrisation. The algorithm return the unique such element in 1+pZZ_p.

INPUT:

  • P - a point on the elliptic curve.

  • prec - the p-adic precision, default is 20.

darmonpoints.util.point_radius(z, level=1)[source]

Returns the vertex corresponding to the affinoid in the p-adic upper half plane that a given (unramified!) point reduces to.

INPUT:

  • z - an element of an unramified extension of QQ_p that is not contained in QQ_p.

OUTPUT:

darmonpoints.util.polynomial_roots(f, K)[source]

Finds the roots of f in the field K, using Hensel lift.

TESTS:

sage: from darmonpoints.util import polynomial_roots
sage: x = QQ['x'].gen()
sage: K.<g> = Qp(5,20).extension(x^2-x-13)
sage: f = x^8 - 576*x^6 + 86568*x^4 - 731648*x^2 + 3283344
sage: alpha = polynomial_roots(f, K)[0]
sage: alpha.precision_absolute()
20
sage: f(alpha)
O(5^20)
darmonpoints.util.polynomial_roots_old(f, K)[source]
darmonpoints.util.print_padic(x)[source]
darmonpoints.util.print_table_latex(self, header_string=None)[source]

LaTeX representation of a table.

If an entry is a Sage object, it is replaced by its LaTeX representation, delimited by dollar signs (i.e., x is replaced by $latex(x)$). If an entry is a string, the dollar signs are not automatically added, so tables can include both plain text and mathematics.

EXAMPLES:

sage: from sage.misc.table import table
sage: a = [[r'$\sin(x)$', '$x$', 'text'], [1,34342,3], [identity_matrix(2),5,6]]
sage: latex(table(a)) # indirect doctest
\begin{tabular}{lll}
$\sin(x)$ & $x$ & text \\
$1$ & $34342$ & $3$ \\
$\left(\begin{array}{rr}
1 & 0 \\
0 & 1
\end{array}\right)$ & $5$ & $6$ \\
\end{tabular}
sage: latex(table(a, frame=True, align='center'))
\begin{tabular}{|c|c|c|} \hline
$\sin(x)$ & $x$ & text \\ \hline
$1$ & $34342$ & $3$ \\ \hline
$\left(\begin{array}{rr}
1 & 0 \\
0 & 1
\end{array}\right)$ & $5$ & $6$ \\ \hline
\end{tabular}
darmonpoints.util.quaternion_algebra_invariants_from_ramification(F, I, S=None, optimize_through_magma=True, magma=None)[source]

Creates a quaternion algebra over a number field which ramifies exactly at the specified places. The algorithm is inspired by the current MAGMA implementation by John Voight.

Warning

At the moment the algorithm requires F to be of narrow class number one. This is only needed when calling the routine weak_approximation, whose current implementation is done under this assumption.

INPUT:

  • F - a number field

  • I - an ideal in F

  • S - (default: None) a list of real embeddings or real places of F

OUTPUT:

  • a quaternion algebra of discriminant I and whose set of infinite ramified places is S

EXAMPLES:

sage: F.<r> = QuadraticField(5)
sage: from darmonpoints.util import quaternion_algebra_invariants_from_ramification
sage: quaternion_algebra_invariants_from_ramification(F,F.ideal(11),[]); # random #  optional - magma
(22, -22*r - 31)
sage: F.<r> = NumberField(x^2 - x - 24)
sage: D = F.ideal(106*r + 469)
sage: S = [F.real_places()[0]]
sage: a, b = quaternion_algebra_invariants_from_ramification(F,D,S) #  optional - magma
sage: B = QuaternionAlgebra(F,a,b) #  optional - magma
sage: B.discriminant() == D #  optional - magma
True
sage: a, b = quaternion_algebra_invariants_from_ramification(F,r+1,[]) #  optional - magma
sage: B = QuaternionAlgebra(F,a,b) #  optional - magma
sage: B.discriminant() == F.ideal(r + 1) #  optional - magma
True
sage: a,b = B.invariants() #  optional - magma
sage: all([v(a) > 0 or v(b) > 0 for v in F.real_places()]) #  optional - magma
True

The number of ramified places must be even:

sage: F.<r> = NumberField(x^2 - x - 24) sage: a, b = quaternion_algebra_invariants_from_ramification(F,r+4,[]) # optional - magma Traceback (most recent call last): … ValueError: Number of ramified places must be even

darmonpoints.util.quaternion_to_magma_quaternion(Bmagma, x)[source]
darmonpoints.util.real_part(a)[source]
darmonpoints.util.recognize_DV_algdep(J, degree, height_threshold=None, prime_bound=None, roots_of_unity=None, outfile=None)[source]
darmonpoints.util.recognize_DV_lindep(J, M, prime_list, Cp=None, units=None, extra_periods=None, outfile=None, **kwargs)[source]

TESTS:

sage: from darmonpoints.util import recognize_DV_lindep
sage: x = QQ['x'].gen()
sage: K.<g> = Qp(3, 50).extension(x^2 - x - 13)
sage: J = 2263329212681251489468 + 6644010739654744556634*g + O(3^46)
sage: M.<a> = NumberField(x^8 - 576*x^6 + 86568*x^4 - 731648*x^2 + 3283344)
sage: Jrec = recognize_DV_lindep(J, M, [2,23,31], algebraic=True)[0]
# SUCCESS!
...
darmonpoints.util.recognize_J(E, J, K, local_embedding=None, known_multiple=1, twopowlist=None, prec=None, outfile=None, qEpows=None)[source]
darmonpoints.util.recognize_point(x, y, E, F, prec=None, HCF=None, E_over_HCF=None)[source]
darmonpoints.util.reduce_word(word)[source]

Simplifies the given word by cancelling out [g^a, g^b] -> [g^(a+b)], and [g^0] -> []

darmonpoints.util.reduce_word_tietze(word)[source]

Simplifies the given word by cancelling out [g, -g] -> []

darmonpoints.util.relativize_ATR(F, ff)[source]
darmonpoints.util.sage_F_elt_to_magma(F_magma, x)[source]
darmonpoints.util.sage_F_ideal_to_magma(F_magma, x)[source]
darmonpoints.util.sage_order_basis_to_pari(w, Ap, basis)[source]
darmonpoints.util.sage_quaternion_to_magma(B_magma, x)[source]
darmonpoints.util.selmer_group_iterator(self, S, m, proof=True)[source]

Return an iterator through elements of the finite group K(S,m). [1, -1, 13, -13, 11, -11, 143, -143]

darmonpoints.util.set_immutable(x)[source]
darmonpoints.util.simplification_isomorphism(G, return_inverse=False)[source]

Return an isomorphism from self to a finitely presented group with a (hopefully) simpler presentation.

EXAMPLES:

sage: from sage.groups.free_group import FreeGroup
sage: G.<a,b,c> = FreeGroup()
sage: H = G / [a*b*c, a*b^2, c*b/c^2]
sage: I = H.simplification_isomorphism()
sage: I # random
Generic morphism:
  From: Finitely presented group < a, b, c | a*b*c, a*b^2, c*b*c^-2 >
  To:   Finitely presented group < b |  >
sage: I(a), I(b), I(c) # random
b^-2, b, b

TESTS:

sage: from sage.groups.free_group import FreeGroup
sage: F = FreeGroup(1)
sage: G = F.quotient([F.0])
sage: G.simplification_isomorphism() # random
Generic morphism:
  From: Finitely presented group < x | x >
  To:   Finitely presented group <  |  >
  Defn: x |--> 1

ALGORITM:

Uses GAP.

darmonpoints.util.solve_quadratic(f, K=None, return_all=False)[source]
darmonpoints.util.syllables_to_tietze(wd)[source]
darmonpoints.util.tate_parameter(E, R)[source]
darmonpoints.util.tietze_to_syllables(wd)[source]

Converts a word in Magma format into our own format.

TESTS:

sage: from darmonpoints.util import tietze_to_syllables sage: short = tietze_to_syllables([1,1,-3,-3,-3,2,2,2,2,2,-1,-1,-1]); short [(0, 2), (2, -3), (1, 5), (0, -3)]

darmonpoints.util.translate_into_twosided_list(V)[source]
darmonpoints.util.update_progress(progress, msg='')[source]
darmonpoints.util.weak_approximation(self, I=None, S=None, J=None, T=None)[source]

Weak approximation at finite places if a number field

Warning

When S or T are non-empty, it is only implemented for number fields of narrow class number 1.

INPUT:

  • I - a fractional ideal (trivial by default) of self.

  • S - a list (empty by default) of real places of self.

  • J - a fractional ideal (trivial by default) of self.

  • T - a list (empty by default) of real places of self.

OUTPUT:

An element x in self satisfying:
  1. v_p(x) = v_p(I) for all prime ideals p dividing I.

  2. v_p(x) = 0 for all prime ideals p dividing J.

  3. v_p(x) geq 0 for all prime ideals coprime to I``+``J.

  4. v(x) < 0 for all places v in S.

  5. v(x) > 0 for all places v in T.

EXAMPLES:

sage: from darmonpoints.util import weak_approximation
sage: F.<r> = NumberField(x^2 - x - 24)
sage: P3 = F.prime_above(3)
sage: P11 = F.prime_above(11)
sage: a = weak_approximation(F, P3^2 * P11^3); a
196*r + 141
sage: a.valuation(P3)
2
sage: a.valuation(P11)
3
sage: F.<r> = NumberField(x^4 - x -1)
sage: P = F.prime_above(7)
sage: Q = F.prime_above(13)
sage: R = F.prime_above(23)
sage: b = weak_approximation(F,P * Q * R); b
-r^3 + 9*r^2 + 28*r - 19
sage: b.valuation(P), b.valuation(Q), b.valuation(R)
(1, 1, 1)
sage: F.<r> = NumberField(x^4 - x - 12)
sage: weak_approximation(F,S = [F.real_places()[0]], T =[F.real_places()[1]])
11*r^3 - 43*r^2 - 32*r + 143