sagemath / cypari2

Python interface to the number theory library PARI/GP. Source repository for https://pypi.org/project/cypari2/
https://cypari2.readthedocs.io/en/latest/
GNU General Public License v2.0
30 stars 28 forks source link

precision parameter does not work with mfeval? #162

Closed user202729 closed 2 months ago

user202729 commented 2 months ago
mf = pari.mfinit([1,4],3)
[f] = pari.mfbasis(mf)
pari.set_real_precision_bits(64)  # default
pari.mfeval(mf, f, pari("I"), precision=400)  # explicitly override here, doesn't work

In the last line, precision=400 is explicitly passed but the output only has 64 bits.

Any idea?

roed314 commented 2 months ago

When I look at the documentation for mfeval, I don't see any precision argument. My guess is that you just have to use the global set_real_precision_bits.

user202729 commented 2 months ago

Setting that work, but there's a few similar cases in SageMath source code where precision is passed (although to a different function)

src/sage/databases/cremona.py:        E = pari(alist).ellinit(precision=ft)
src/sage/databases/cremona.py:        E = pari(alist).ellinit(precision=ft)
src/sage/schemes/elliptic_curves/period_lattice.py:            # The precision for omega() is determined by ellinit()
src/sage/schemes/elliptic_curves/period_lattice.py:            E_pari = pari.ellinit(ainvs, precision=prec)

I'm not sure what's going on. (the "library syntax" at the bottom, which if I understood correctly means the C API instead of GP scripting language, says bitprec can be passed)

user202729 commented 2 months ago

actually precision can be used to decrease precision, but not increase it:

sage: mf = pari.mfinit([1,4],3)
....: [f] = pari.mfbasis(mf)
sage: pari.set_real_precision_bits(64)
....: pari.mfeval(mf, f, pari("I"), precision=400)
0.006065678717786288844
sage: pari.set_real_precision_bits(400)
....: pari.mfeval(mf, f, pari("I"), precision=400)
0.00606567871778628884359342501499528869763497743970084789882853707625021574461901420877704921867358230481037126231595491218
sage: pari.set_real_precision_bits(400)
....: pari.mfeval(mf, f, pari("I"), precision=64)
0.0060656787177862888435928388224507233518
                         ^^^^^^^^^^^^^^^^^ incorrect

Maybe it's just unclear documentation on pari side.