# Float-point precision in instantiation of point in Hyperbolic geometry module

I'm in the middle of debugging some other codebase (working in a Poincare Disk of hyperbolic-geometry) and I figured that the following specific point causing the issue. Now, I would like to instantiate the point based on the that coordinate. But the result of printing on console indicates that the last few digits have been rounded...

from sage.geometry.hyperbolic_space.hyperbolic_interface import HyperbolicPlane

# Instantiate HyperbolicPlane
PD = HyperbolicPlane().PD()

p = PD.get_point(CC(0.13816890584139213 + 0.4878012008585488*I))
print(p)  # -> Point in PD 0.138168905841392 + 0.487801200858549*I


Could anyone help me instantiate the point on this particular coordinate?

edit retag close merge delete

Here is the link to the above code on Sage Maths Cell server: https://sagecell.sagemath.org/?q=mzkxqj

( 2024-02-26 14:58:31 +0200 )edit

Sort by ยป oldest newest most voted

Let us see what is exactly CC. For this, we compare:

sage: CC(0.13816890584139213)
0.138168905841392
sage: CC
Complex Field with 53 bits of precision
sage: CC(0.1234567890123456789012345678901234567890)
0.123456789012346


The first input corresponds to initializing the real part of the wanted point. Instead of 0.13816890584139213 we have a printed version going only up to 0.138168905841392. Sometimes the printed version is such a rough information. So what is CC. It is an object collecting inexact information, only $53$ bits are collected. So from the next test number we have only 0.123456789012346. If we try to print more... print(a.n(200)) runs into a TypeError: cannot approximate to a precision of 200 bits, use at most 53 bits...

C = ComplexField(150)
print(f"C is {C}")

PD = HyperbolicPlane().PD()
p = PD.get_point(C(0.138168905841392130000000000) + C(0.4878012008585488000000000)*i)    # our C instead of CC

print(p)


And we obtain:

C is Complex Field with 150 bits of precision
Point in PD 0.13816890584139213000000000000000000000000000 + 0.48780120085854880000000000000000000000000000*I


We have the decimals we want...

more

@dan_fulea Thank you so much for your answer! I confirmed that this works as you described!

( 2024-02-26 21:58:37 +0200 )edit

Alternate possibility : PD.get_point() does accept rational coordinates :

sage: p = PD.get_point(1/7+I/2); p
Point in PD 1/2*I + 1/7


Can you try to determine p's exact coordinates (possibly by other means) ? I mean coordinates in QQbar.

Using the current data, you can try to convert (a bit awkwardly) from the CC-derived representation :

sage: pprime=PD.get_point((lambda a,b:a+I*b)(*[f(p.coordinates()).exact_rational() for f in (real, imag)])) ; pprime
Point in PD 2196861306417441/4503599627370496*I + 2489029731445931/18014398509481984


HTH,

more