compute regulator of quadratic field

24 views
Skip to first unread message

Michael Beeson

unread,
Jul 24, 2019, 10:43:10 AM7/24/19
to sage-support
SageMath has built-in functions to compute the regulator and the fundamental unit of a quadratic field.  The regulator of a quadratic field is the log of the absolute value of the fundamental unit.
So,  the following code should print out the same number on each line.  But, as you can check,  it does so only some of the time.  Try checkRegulator(30)  for example.    I am using version 8.7.
I also wrote other code (not included here)  based on the Dedekind zeta function  to compute the regulator.  It agrees with SageMath's "regulator" function  rather than with log of the fundamental unit.

def checkRegulator(N):
for d in range(3,N):
if not is_squarefree(d):
continue
K.<a> = QuadraticField(d)
G = K.unit_group()
u = G.gen(1).value();
Rdirect = abs(n(log(u)))
RSage = K.regulator()
print(d,RSage,Rdirect)

Nils Bruin

unread,
Jul 24, 2019, 3:51:28 PM7/24/19
to sage-support
I think your problem is here: you need to take abs(u) before taking the log; otherwise you can get some funny complex number back. You also want to take the embedding into R that is larger than 1 in absolute value, but if you take the abs of the log afterwards it doesn't matter.
 
RSage = K.regulator()
print(d,RSage,Rdirect)
Reply all
Reply to author
Forward
0 new messages