Skip to content

Commit

Permalink
Print numbers consistently on Python 2 and 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Mar 11, 2019
1 parent 3ff19c1 commit 901eaf8
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/sage/schemes/elliptic_curves/height.py
Expand Up @@ -1902,7 +1902,7 @@ def min_gr(self, tol, n_max, verbose=False):
sage: K.<i> = QuadraticField(-1)
sage: E = EllipticCurve([0,1-i,i,-i,0])
sage: H = E.height_function()
sage: H.min_gr(0.01,5)
sage: H.min_gr(0.01, 5) # long time
0.020153685521979152
In this example the point `P=(0,0)` has height 0.023 so our
Expand All @@ -1927,11 +1927,10 @@ def min_gr(self, tol, n_max, verbose=False):
This example from the LMFDB gave problems before the fix in :trac:`8829`::
sage: K.<a> = NumberField(x^2-x-1)
sage: phi = a
sage: K.<phi> = NumberField(x^2-x-1)
sage: E = EllipticCurve([phi + 1, -phi + 1, 1, 20*phi - 39, 196*phi + 237])
sage: H = E.height_function()
sage: H.min_gr(.1,5,True) # long time (~22s)
sage: H.min_gr(.1, 5, verbose=True) # long time (~22s)
B_1(1) = 1540.199246369678
...
halving mu to 0.25 and increasing n_max to 6
Expand All @@ -1941,42 +1940,42 @@ def min_gr(self, tol, n_max, verbose=False):
doubling mu to 0.015625
height bound in [0.0078125, 0.015625] using n_max = 13
...
height bound in [0.0120485220735, 0.0131390064883] using n_max = 13
height bound in [0.012048522073499539, 0.01313900648833929] using n_max = 13
0.012048522073499539
"""
test = self.test_mu
if test(1, n_max, verbose):
mu = 2
mu = 2.0
while test(mu, n_max, False):
mu *= 2
mu /= 2
mu *= 0.5
else:
mu = .5
mu = 0.5
while not test(mu, n_max, False):
mu /= 2
mu *= 0.5
n_max += 1
if verbose:
print("halving mu to %s and increasing n_max to %s" % (mu,n_max))
print("halving mu to %r and increasing n_max to %r" % (mu, n_max))
# now we have (mu,n_max) which work we can try to increase
# mu again using this larger n_max:
mu *= 2
while test(mu, n_max, False):
mu *= 2
if verbose:
print("doubling mu to %s" % mu)
mu /= 2
print("doubling mu to %r" % mu)
mu *= 0.5

# The true value lies between mu and eps * mu.
eps = 2.0
while eps > tol + 1:
if verbose:
print("height bound in [%s, %s] using n_max = %s"
print("height bound in [%r, %r] using n_max = %r"
% (mu, mu * eps, n_max))
eps = math.sqrt(eps)
if test(mu * eps, n_max, False):
mu = mu * eps
if verbose:
print("height bound in [%s, %s] using n_max = %s"
print("height bound in [%r, %r] using n_max = %r"
% (mu, mu * eps, n_max))
return RDF(mu)

Expand Down

0 comments on commit 901eaf8

Please sign in to comment.