Klein's elliptic modular j-invariant, or j function in short, has a notable property that the special value for the imaginary quadratic irrational numbers can be computed exactly. The following is the algorithm implemented in Maxima in this notebook.
InFD(p) p is a complex number. InFD(p)
checks if p is in the fundamental domain of $j(z)$.
FindInFD(p) p is a complex number. FindInFD(p)
returns a complex number in the fundamental domain and equivalent to p. It shows the necessary transformations, too.
float_modular_j(t) t is a complex float number. float_modular_j(t)
numerically computes the value of $j(t)$.
FindReducedQuadIrrD(D) D is an integer. FindReducedQuadIrrD(D)
computes the list of all the reduced imaginary quadratic irrational numbers whose determinant is $D$.
FindClassNumberD(D) D is an integer. FindClassNumberD(D)
computes the class number of the determinant $D$.
FindClassPolyD(var,D) var is a variable, D is an integer. FindClassPolyD(var,D)
computes the Hilbert class polynomial of variable $var$, the determinant equal to $D$.
exact_modular_j(t) t is an imaginary quadratic irrational number of the form $ \frac{a_1+a_2\,\sqrt{a_3}}{a_4} $ where $a_1,\cdots,a_4$ are integers, $a_2, a_4$ positive and $a_3$ negative. exact_modular_j(t)
computes the exact value (which is an algebraic number) of $j(t)$ using the above algorithm.
install_github("YasuakiHonda","modular_j","main")$
asdf_load("modular_j")$
p:(1+sqrt(-3))/2;
float_modular_j(p);
exact_modular_j(p);
p:(1+sqrt(-15))/2;
exact_modular_j(p),factor;
%,numer;
float_modular_j(p);
p:(-1+sqrt(-23))/2;
D:FindDetIrr(p);
FindReducedQuadIrrD(D);
FindClassNumberD(D);
FindClassPolyD(x,D);
exact_modular_j(p),factor;
bfloat(%),fpprec:32;
bfloat_modular_j(p),fpprec:32;
FindClassPolyD(x,D),x:bfloat_modular_j(p),fpprec:32;