Ask Your Question
1

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

asked 2024-02-26 14:55:35 +0100

Rowing0914 gravatar image

updated 2024-02-26 14:56:48 +0100

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 flag offensive close merge delete

Comments

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

Rowing0914 gravatar imageRowing0914 ( 2024-02-26 14:58:31 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2024-02-26 17:05:55 +0100

dan_fulea gravatar image

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...

So let us try from the start with a higher precision:

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...

edit flag offensive delete link more

Comments

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

Rowing0914 gravatar imageRowing0914 ( 2024-02-26 21:58:37 +0100 )edit
1

answered 2024-02-27 14:12:04 +0100

Emmanuel Charpentier gravatar image

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,

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-02-26 14:55:35 +0100

Seen: 254 times

Last updated: Feb 27