Does anyone know how to find explicit generators for the unit group of a number field on magma?


For example, in sage one could do



> 
> K. = NumberField(x^3+x^2-2\*x-1)
> 
> 
> UnitGroup(K).gens()
> 
> 
> 


and it gives you [-1, w^2 - 1, w + 1] which generate the unit group, but I can't figure out how to get this same data in magma.


Alternatively if anyone knows how to tell if something is totally positive in sage, that would work too.



magma generators for unit group/ sage totally positive
In Magma, the unit group is returned as an abstract group together with a map from that group into the field. So you would do something like the following:



```
> Zx<x> := PolynomialRing(Integers());
> K<w> := NumberField(x^3 + x^2 - 2*x - 1);
> G,phi := UnitGroup(K);
> G;
Abelian Group isomorphic to Z/2 + Z + Z
Defined on 3 generators
Relations:
    2*G.1 = 0
> [ K!phi(G.i) : i in [1..Ngens(G)] ];
[
  -1,
  w,
  w + 1
]

```

Note a couple of important points here. Firstly, for some reason calling Generators(G) would return a set rather than the more helpful sequence, hence the use of G.i and the loop over Ngens. Secondly, the concept of units is only useful with respect to an order, not the field, so the map phi is actually from G to the maximal order of K. That is why I have inserted the coercion into K, since that seems closer to what you want.


