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

AlgebraicField.numer() could return an algebraic integer #14380

Open
skirpichev opened this Issue Mar 4, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@skirpichev
Copy link
Contributor

skirpichev commented Mar 4, 2018

Right now, numer() and denom() methods are copy-pasted from Ring class and not too much useful.

In [12]: A = QQ.algebraic_field(1/sqrt(2))

In [13]: A.ext.to_algebraic_integer()
Out[13]: √2

In [14]: A.numer(A([1, 0]))
Out[14]: ANP([1, 0], [mpq(2,1), mpq(0,1), mpq(-1,1)], QQ)

In [15]: A.denom(A([1, 0]))
Out[15]: ANP([mpq(1,1)], [mpq(2,1), mpq(0,1), mpq(-1,1)], QQ)

I think, it will make more sense if _14 be sqrt(2) and _15 is 2 (i.e. denom() will do that AlgebraicNumberDenominator Mathematica's method does).

@jksuom

This comment has been minimized.

Copy link
Member

jksuom commented Mar 5, 2018

I agree, but I am not sure how this should be implemented. Maybe to_number_field(ext), creating the generator of QQ.algebraic_field(ext), should first be modified to always return an algebraic integer. Then all elements of the field could be represented as polynomials in the generator with integer coefficients (numer) divided by a common integer (denom).

@skirpichev

This comment has been minimized.

Copy link
Contributor

skirpichev commented Mar 5, 2018

Seems to be a good idea. Or just "canonicalize" in this way the ext, returned by to_number_field in the AlgebraicField constructor.

@skirpichev

This comment has been minimized.

Copy link
Contributor

skirpichev commented Jun 3, 2018

I seems, implemented in AlgebraicNumber.to_algebraic_integer() algorithm produces not simplest algebraic integers. For example, here we have extra factor 2:

In [3]: AlgebraicNumber(sqrt(3)/2, gen=x).to_algebraic_integer()
Out[3]: 2⋅√3

skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 4, 2018

skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 4, 2018

skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 4, 2018

skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 5, 2018

skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment