Ask Your Question

compute regulator with more precision

asked 2021-12-27 03:10:10 +0100

beeson gravatar image

updated 2022-01-22 06:07:28 +0100

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):
                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
                if x != x2 or y != y2:
                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)                                           
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 flag offensive close merge delete


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

Max Alekseyev gravatar imageMax Alekseyev ( 2021-12-27 19:31:24 +0100 )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".


Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-12-27 22:58:52 +0100 )edit
slelievre gravatar imageslelievre ( 2021-12-28 07:12:38 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-12-27 19:05:47 +0100

beeson gravatar image

Someone pointed me to Maurer's dissertation:

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

edit flag offensive delete link more


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

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-12-27 23:01:46 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2021-12-27 03:10:10 +0100

Seen: 55 times

Last updated: yesterday