ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 28 Dec 2021 07:12:38 +0100compute regulator with more precisionhttps://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/I want to compute the regulator of a real quadratic field Q(sqrt d) to high precision,
accurately enough to compute the fundamental unit. The default
breaks at d = 331 where fundamental unit needs more than 53 bits (the precision of doubles). The documentation says that Pari computes to a higher precision than
SageMath. Also somewhere it says that if you get a good enough approximation to the regulator, it's trivial to refine it to high accuracy. It refers to "the tutorial" without a link; I read the Pari-GP tutorials on algebraic number theory without finding any explanation of that remark. So actually there are two questions here: point me to an explanation of refining the computation of the regulator, and secondly, fix the following code
so that it doesn't print "oops" when d = 331. Sorry, I don't know how to get the code to display
with newlines and tabs correct. It looks right when I edit the post.
gp.set_real_precision(256) # doesn't seem to do anything
def check_unit(N):
for d in range(10,N):
if not is_squarefree(d):
continue
K.<a> = QuadraticField(d)
G = K.unit_group()
[x,y] = G.gen(1).value()
x = abs(x)
R = K.regulator(None)
twox = round(exp(R))
x2 = twox/2
y2 = round(twox/sqrt(d))/2
print(d,x,x2,y,y2,exp(R)/2)
if x != x2 or y != y2:
print("oops!")
return
if norm_is_negative(x,d):
print("norm is negative")
A shorter "minimal non-working example":
sage: d = 2352721672669
sage: K.<a> = QuadraticField(d)
sage: gp.default("realprecision",256)
0
sage: R = K.regulator()
followed by many error messages.
Later: well, precision 512 seems to work. So I guess it's just that 256 isn't enough!Mon, 27 Dec 2021 03:10:10 +0100https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/Comment by slelievre for <p>I want to compute the regulator of a real quadratic field Q(sqrt d) to high precision,
accurately enough to compute the fundamental unit. The default
breaks at d = 331 where fundamental unit needs more than 53 bits (the precision of doubles). The documentation says that Pari computes to a higher precision than
SageMath. Also somewhere it says that if you get a good enough approximation to the regulator, it's trivial to refine it to high accuracy. It refers to "the tutorial" without a link; I read the Pari-GP tutorials on algebraic number theory without finding any explanation of that remark. So actually there are two questions here: point me to an explanation of refining the computation of the regulator, and secondly, fix the following code
so that it doesn't print "oops" when d = 331. Sorry, I don't know how to get the code to display
with newlines and tabs correct. It looks right when I edit the post.</p>
<pre><code>gp.set_real_precision(256) # doesn't seem to do anything
def check_unit(N):
for d in range(10,N):
if not is_squarefree(d):
continue
K.<a> = QuadraticField(d)
G = K.unit_group()
[x,y] = G.gen(1).value()
x = abs(x)
R = K.regulator(None)
twox = round(exp(R))
x2 = twox/2
y2 = round(twox/sqrt(d))/2
print(d,x,x2,y,y2,exp(R)/2)
if x != x2 or y != y2:
print("oops!")
return
if norm_is_negative(x,d):
print("norm is negative")
</code></pre>
<p>A shorter "minimal non-working example":</p>
<pre><code>sage: d = 2352721672669
sage: K.<a> = QuadraticField(d)
sage: gp.default("realprecision",256)
0
sage: R = K.regulator()
</code></pre>
<p>followed by many error messages.</p>
<p>Later: well, precision 512 seems to work. So I guess it's just that 256 isn't enough!</p>
https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/?comment=60470#post-id-60470Also asked at
- [sage-support, 2021-12: regulator](https://groups.google.com/g/sage-support/c/xM2LSzY6vh4)Tue, 28 Dec 2021 07:12:38 +0100https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/?comment=60470#post-id-60470Comment by Emmanuel Charpentier for <p>I want to compute the regulator of a real quadratic field Q(sqrt d) to high precision,
accurately enough to compute the fundamental unit. The default
breaks at d = 331 where fundamental unit needs more than 53 bits (the precision of doubles). The documentation says that Pari computes to a higher precision than
SageMath. Also somewhere it says that if you get a good enough approximation to the regulator, it's trivial to refine it to high accuracy. It refers to "the tutorial" without a link; I read the Pari-GP tutorials on algebraic number theory without finding any explanation of that remark. So actually there are two questions here: point me to an explanation of refining the computation of the regulator, and secondly, fix the following code
so that it doesn't print "oops" when d = 331. Sorry, I don't know how to get the code to display
with newlines and tabs correct. It looks right when I edit the post.</p>
<pre><code>gp.set_real_precision(256) # doesn't seem to do anything
def check_unit(N):
for d in range(10,N):
if not is_squarefree(d):
continue
K.<a> = QuadraticField(d)
G = K.unit_group()
[x,y] = G.gen(1).value()
x = abs(x)
R = K.regulator(None)
twox = round(exp(R))
x2 = twox/2
y2 = round(twox/sqrt(d))/2
print(d,x,x2,y,y2,exp(R)/2)
if x != x2 or y != y2:
print("oops!")
return
if norm_is_negative(x,d):
print("norm is negative")
</code></pre>
<p>A shorter "minimal non-working example":</p>
<pre><code>sage: d = 2352721672669
sage: K.<a> = QuadraticField(d)
sage: gp.default("realprecision",256)
0
sage: R = K.regulator()
</code></pre>
<p>followed by many error messages.</p>
<p>Later: well, precision 512 seems to work. So I guess it's just that 256 isn't enough!</p>
https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/?comment=60466#post-id-60466> Sorry, I don't know how to get the code to display with newlines and tabs correct. It looks right when I edit the post.
Use the `101010` button to insert the text of your code ; alternatively, select your code and use Ctrl-K : in both case, your code willbe isolated by newlines and indented with four spaces, which is interpreted as "respect newlines and indentation".
HTH,Mon, 27 Dec 2021 22:58:52 +0100https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/?comment=60466#post-id-60466Comment by Max Alekseyev for <p>I want to compute the regulator of a real quadratic field Q(sqrt d) to high precision,
accurately enough to compute the fundamental unit. The default
breaks at d = 331 where fundamental unit needs more than 53 bits (the precision of doubles). The documentation says that Pari computes to a higher precision than
SageMath. Also somewhere it says that if you get a good enough approximation to the regulator, it's trivial to refine it to high accuracy. It refers to "the tutorial" without a link; I read the Pari-GP tutorials on algebraic number theory without finding any explanation of that remark. So actually there are two questions here: point me to an explanation of refining the computation of the regulator, and secondly, fix the following code
so that it doesn't print "oops" when d = 331. Sorry, I don't know how to get the code to display
with newlines and tabs correct. It looks right when I edit the post.</p>
<pre><code>gp.set_real_precision(256) # doesn't seem to do anything
def check_unit(N):
for d in range(10,N):
if not is_squarefree(d):
continue
K.<a> = QuadraticField(d)
G = K.unit_group()
[x,y] = G.gen(1).value()
x = abs(x)
R = K.regulator(None)
twox = round(exp(R))
x2 = twox/2
y2 = round(twox/sqrt(d))/2
print(d,x,x2,y,y2,exp(R)/2)
if x != x2 or y != y2:
print("oops!")
return
if norm_is_negative(x,d):
print("norm is negative")
</code></pre>
<p>A shorter "minimal non-working example":</p>
<pre><code>sage: d = 2352721672669
sage: K.<a> = QuadraticField(d)
sage: gp.default("realprecision",256)
0
sage: R = K.regulator()
</code></pre>
<p>followed by many error messages.</p>
<p>Later: well, precision 512 seems to work. So I guess it's just that 256 isn't enough!</p>
https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/?comment=60465#post-id-60465to change real precision in gp run `gp.default("realprecision",256)`Mon, 27 Dec 2021 19:31:24 +0100https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/?comment=60465#post-id-60465Answer by beeson for <p>I want to compute the regulator of a real quadratic field Q(sqrt d) to high precision,
accurately enough to compute the fundamental unit. The default
breaks at d = 331 where fundamental unit needs more than 53 bits (the precision of doubles). The documentation says that Pari computes to a higher precision than
SageMath. Also somewhere it says that if you get a good enough approximation to the regulator, it's trivial to refine it to high accuracy. It refers to "the tutorial" without a link; I read the Pari-GP tutorials on algebraic number theory without finding any explanation of that remark. So actually there are two questions here: point me to an explanation of refining the computation of the regulator, and secondly, fix the following code
so that it doesn't print "oops" when d = 331. Sorry, I don't know how to get the code to display
with newlines and tabs correct. It looks right when I edit the post.</p>
<pre><code>gp.set_real_precision(256) # doesn't seem to do anything
def check_unit(N):
for d in range(10,N):
if not is_squarefree(d):
continue
K.<a> = QuadraticField(d)
G = K.unit_group()
[x,y] = G.gen(1).value()
x = abs(x)
R = K.regulator(None)
twox = round(exp(R))
x2 = twox/2
y2 = round(twox/sqrt(d))/2
print(d,x,x2,y,y2,exp(R)/2)
if x != x2 or y != y2:
print("oops!")
return
if norm_is_negative(x,d):
print("norm is negative")
</code></pre>
<p>A shorter "minimal non-working example":</p>
<pre><code>sage: d = 2352721672669
sage: K.<a> = QuadraticField(d)
sage: gp.default("realprecision",256)
0
sage: R = K.regulator()
</code></pre>
<p>followed by many error messages.</p>
<p>Later: well, precision 512 seems to work. So I guess it's just that 256 isn't enough!</p>
https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/?answer=60464#post-id-60464Someone pointed me to Maurer's dissertation:
https://tuprints.ulb.tu-darmstadt.de/87/
which answers the theoretical part of my question. But that still leaves the second part unanswered.Mon, 27 Dec 2021 19:05:47 +0100https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/?answer=60464#post-id-60464Comment by Emmanuel Charpentier for <p>Someone pointed me to Maurer's dissertation:</p>
<p><a href="https://tuprints.ulb.tu-darmstadt.de/87/">https://tuprints.ulb.tu-darmstadt.de/87/</a></p>
<p>which answers the theoretical part of my question. But that still leaves the second part unanswered.</p>
https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/?comment=60467#post-id-60467Doesn't Max Alexeyev's comment solve the problem ?Mon, 27 Dec 2021 23:01:46 +0100https://ask.sagemath.org/question/60455/compute-regulator-with-more-precision/?comment=60467#post-id-60467