Half-periods ratio for the $\wp$-Weierstrass function

112 Views Asked by At

Given the two elliptic invariants $g_2$, $g_3$ of the $\wp$-Weierstrass function, I have the following code to get the half-periods ratio $\tau$:

r <- polyroot(c(-g3, -g2, 0, 4)) # roots of 4*t^3 - g2*t - g3 = 0
r1 <- r[1]
r2 <- r[2]
r3 <- r[3]
a <- sqrt(r1 - r3)
b <- sqrt(r1 - r2)
c <- sqrt(r2 - r3)
if(abs(a + b) < abs(a - b)) b <- -b
if(abs(a + c) < abs(a - c)) c <- -c
if(abs(c + 1i*b) < abs(c - 1i*b)){ # 1i is the imaginary unit
  e3 <- r1
  a <- sqrt(r3 - r1)
  b <- sqrt(r3 - r2)
  c <- sqrt(r2 - r1)
  w1 <- 1 / agm(1i*b, c) # agm is the arithmetic-geometric mean
}else{
  w1 <- 1 / agm(a, b)
}
w3 <- 1i / agm(a, c)
tau <- w3 / w1 # half-periods ratio

I absolutely don't remember where I found this algorithm. And I realized that the order of the roots of the polynomial (first line) is important. For example the roots must be in ascending order when there are reals. Would you know what is the general rule for the order of the roots in this algorithm?