im in AcbField/ComplexField and other constants

4 views
Skip to first unread message

Grégory Vanuxem

unread,
Apr 3, 2024, 7:12:12 AMApr 3
to Nemo-Devel
Hello,

I am writing an interface to the Julia Nemo package and am facing the
problem of generating the Julia 'im' constant in the number fields
mentioned in the object of this email. Is there a way to obtain it in
another way than with sqrt(-1)?

Here is a Julia session that shows that and other things that could
eventually be easily added to Nemo.

=====================================================
julia> C=AcbField()
Complex Field with 256 bits of precision and error bounds

julia> R=ArbField()
Real Field with 256 bits of precision and error bounds

julia> CC=ComplexField()
Complex field

julia> const_e(R)
[2.7182818284590452353602874713526624977572470936999595749669676277240766303535
+/- 5.46e-77]

julia> RR=RealField()
Real field

julia> const_e(RR)
[2.718281828459045235 +/- 4.29e-19]

julia> const_pi(C)
[3.1415926535897932384626433832795028841971693993751058209749445923078164062862
+/- 1.93e-77]

julia> const_pi(CC)
[3.141592653589793239 +/- 5.96e-19]

julia> const_e(CC)
ERROR: MethodError: no method matching const_e(::ComplexField)
The function `const_e` exists, but no method is defined for this
combination of argument types.

Closest candidates are:
const_e(::RealField, ::Int64)
@ Nemo ~/.julia/packages/Nemo/9d4V8/src/arb/Real.jl:998
const_e(::RealField)
@ Nemo ~/.julia/packages/Nemo/9d4V8/src/arb/Real.jl:998
const_e(::ArbField)
@ Nemo ~/.julia/packages/Nemo/9d4V8/src/arb/arb.jl:1039

Stacktrace:
[1] top-level scope
@ REPL[32]:1

julia> const_e(C)
ERROR: MethodError: no method matching const_e(::AcbField)
The function `const_e` exists, but no method is defined for this
combination of argument types.

Closest candidates are:
const_e(::RealField, ::Int64)
@ Nemo ~/.julia/packages/Nemo/9d4V8/src/arb/Real.jl:998
const_e(::RealField)
@ Nemo ~/.julia/packages/Nemo/9d4V8/src/arb/Real.jl:998
const_e(::ArbField)
@ Nemo ~/.julia/packages/Nemo/9d4V8/src/arb/arb.jl:1039

Stacktrace:
[1] top-level scope
@ REPL[33]:1

julia> sqrt(CC(-1))
1.0000000000000000000*im

julia> sqrt(C(-1))
1.00000000000000000000000000000000000000000000000000000000000000000000000000000*im

julia>
==================================================

As you can also see, const_e(CC) and const_e(C) are not implemented
for complex number fields whereas const_pi is. Maybe this constant can
also be added to complex number fields. As of now I have not begun to
use exact real/complex number fields using Calcium via Nemo so I do
not know for this, my main question is how to generate 'im' in those
fields without using 'sqrt'.

Kind regards,

- Greg

tho...@gmail.com

unread,
Apr 4, 2024, 4:14:04 AMApr 4
to nemo-devel
Regarding the `im` function. Does the following answer your question?

julia> CC=ComplexField()
Complex field

julia> onei(CC)
1.0000000000000000000*im

julia> CC=AcbField(128)
Complex Field with 128 bits of precision and error bounds

julia> onei(CC)
1.00000000000000000000000000000000000000*im
Reply all
Reply to author
Forward
0 new messages