# 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
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: 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!

edit retag close merge delete

to change real precision in gp run gp.default("realprecision",256)

( 2021-12-27 19:31:24 +0200 )edit

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,

( 2021-12-27 22:58:52 +0200 )edit
( 2021-12-28 07:12:38 +0200 )edit

Sort by ยป oldest newest most voted

Someone pointed me to Maurer's dissertation:

which answers the theoretical part of my question. But that still leaves the second part unanswered.

more

Doesn't Max Alexeyev's comment solve the problem ?

( 2021-12-27 23:01:46 +0200 )edit