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.