Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we make ComplexField(QQ) ? #1110

Closed
zhaoli-IHEP opened this issue Jul 7, 2021 · 9 comments
Closed

Can we make ComplexField(QQ) ? #1110

zhaoli-IHEP opened this issue Jul 7, 2021 · 9 comments

Comments

@zhaoli-IHEP
Copy link

Is it possible to have the rational complex field instead of the float number complex field?
Meanwhile maybe fit into LaurentSeriesField(ComplexField(QQ), 5, "ep")?

@thofma
Copy link
Member

thofma commented Jul 7, 2021

It is already there, but maybe not under the name that you would have in mind.

julia> Qx, x = QQ["x"]
(Univariate Polynomial Ring in x over Rational Field, x)

julia> CC, i = NumberField(x^2 + 1, "i")
(Number field over Rational Field with defining polynomial x^2 + 1, i)

julia> i^2
-1

(https://en.wikipedia.org/wiki/Gaussian_rational)

Do you have a suggestion for an alias? Would you suggest ComplexField(QQ)?

@zhaoli-IHEP
Copy link
Author

It is already there, but maybe not under the name that you would have in mind.

julia> Qx, x = QQ["x"]
(Univariate Polynomial Ring in x over Rational Field, x)

julia> CC, i = NumberField(x^2 + 1, "i")
(Number field over Rational Field with defining polynomial x^2 + 1, i)

julia> i^2
-1

(https://en.wikipedia.org/wiki/Gaussian_rational)

Do you have a suggestion for an alias? Would you suggest ComplexField(QQ)?

So great! Thank you.
I think ComplexField(QQ) would be nice.

@thofma
Copy link
Member

thofma commented Jul 7, 2021

Let's hear what the others think. @wbhart @tthsqe12

@wbhart
Copy link
Contributor

wbhart commented Jul 7, 2021

I don't have any objections. It would be nice if it also worked for Nemo.

@thofma
Copy link
Member

thofma commented Jul 7, 2021

This is a about Nemo.

@tthsqe12
Copy link
Contributor

tthsqe12 commented Jul 7, 2021

I have a reservation about ComplexField(QQ): it suggests that we can do ComplexField(F) for a multitude of fields F, ie extent F by a nonreal something. What is ComplexField(GF(5)) or ComplexField(GF(7))?
If you share my reservations, name them GaussianRationals() and GaussianIntegers(). Otherwise, call it whatever you want. Just make sure all instances hash equal!

On a related note, Complex{fmpq} doesn't work :(

@thofma
Copy link
Member

thofma commented Jul 8, 2021

After sleeping one night over this, I also don't like it too much anymore. It does not really play nice with im and should it return both the field and the imaginary unit? It is also awkward because one needs to use i = gen(K) to get the imaginary unit.

@tthsqe12
Copy link
Contributor

tthsqe12 commented Aug 4, 2021

So, I have come across the need for exactly this kind of thing. There are parents ZZi and QQi with elem types fmpzi and fmpqi. The behaviour is the following (I am not willing to compromise on the denominator(x) != 25 thing).

julia> i = ZZi(im)
im

julia> typeof(ans)
fmpzi

julia> x = (3+4i)//(5+10i)
(11 - 2*im)/25

julia> typeof(ans)
fmpqi

julia> (numerator(x), denominator(x))
(2 + im, 4 + 3*im)

julia> map(factor, ans)
(1 * (2 + im), im * (2 - im)^2)

It is supposed to play nice with the other complex types:

julia> CC = AcbField(50); gamma(CC(1/2,1/3))
[1.1789716859081 +/- 3.88e-14] + [-0.7570793934981 +/- 4.63e-14]*im

julia> simplest_rational_inside(ans)
(38171685330064 - 24512035975001*im)/32377100982424

(This may or may not be the simplest rational inside, it is just for demo purposes)

@fingolfin
Copy link
Member

We won't add ComplexField(QQ) (or complex_field(QQ)) but indeed QQi exists in Nemo, and quadratic_field in Hecke / Oscar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants