
| Current Path : /usr/share/doc/pari-doc/examples/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //usr/share/doc/pari-doc/examples/classno.gp |
\\ --------------- GP code ---------------------------------------
\\
\\ Time-stamp: <Fri, Mar 26, 1999 - 14:13:17 - villegas@linux47>
\\
\\ Description: Compute class number of imaginary quadratic field
\\ analytically
\\
\\ File: classno.gp
\\
\\ Original Author: Fernando Rodriguez-Villegas
\\ villegas@math.utexas.edu
\\ University of Texas at Austin
\\
\\ Created: Fri Mar 26 1999
\\-----------------------------------------------------------------
\\ Class number h(-d), -d fundamental.
\\ Adjust constant cc for accuracy, default at least 9 decimal places.
cl(d, cc = 5) =
{ my(q0,sd,c, s = 0, q = 1);
if (!isfundamental(-d), error("Discriminant not fundamental"));
sd = sqrt(d);
q0 = exp(-2*Pi/sd); c = -4*Pi/sd;
for (n=1, ceil(sd*cc),
my(t);
q *= q0; t = 1/(1-q);
s += kronecker(-d,n) * q * t * (1 + c*t*n)
);
if (d==3, s *= 3,
d==4, s *= 2);
-2*s;
}