These require floating point arithmetic to compute [Cohen p415, BSS p151]. Routines for complex numbers need to be written. For multiplication, using a trick similar to Karatsuba multiplication saves one multiplication. Similarly, for squaring, one should use if multiplication is sufficiently less efficient than addition or subtraction.
To minimize the possbility of underflow, overflow or precision loss, the complex modulus of should be computed as [Numerical Recipes, 5.4] Similarly, division should be implemented as
We will need to compute the function for in the upper complex plane. Set . Define Then compute where
The Hilbert class polynomial for the discriminant is given by where runs over all complex numbers such that where is a primitive reduced positive definite binary quadratic form of discriminant . In other words, , , , and if or then .
Thus can be computed by the following procedure. Let be a polynomial variable. Assume is or .
- Set
- Set and
- If does not divide go to the next step. Otherwise compute . If or or set otherwise set .
- Set . If go to the previous step.
- Set . If go to step 2, otherwise round the coefficients of to the nearest integer and output .