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

Open
opened this Issue Mar 4, 2018 · 3 comments

Projects
None yet
2 participants
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).
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`).
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.
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

``` XXX polys: primitive_element() return an algebraic integer ```
`See sympy/sympy#14380`
``` d5c276a ```

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

``` XXX polys: primitive_element() return an algebraic integer ```
`See sympy/sympy#14380`
``` a1d1995 ```

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

``` XXX polys: primitive_element() return an algebraic integer ```
`See sympy/sympy#14380`
``` 8eb2273 ```

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

``` polys: primitive_element() return an algebraic integer ```
`Closes sympy/sympy#14380`
``` a5fee21 ```

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

``` polys: primitive_element() return an algebraic integer ```
`Closes sympy/sympy#14380`
``` 5347365 ```