Hi,

On 2016-11-23, Friedrich Wiemer <[email protected]> wrote:
> not sure if this make sense: I would like to convert elements
> from a ring to elements in the ring's unit group (with raising
> exceptions, if the ring element is not in the unit group).
> So what I'm looking for is basically the "inversion" of:
> R(R.unit_group().random_element())

Does R.unit_group()(R.random_element()) not do what you describe?

That said, I am not sure if R.unit_group() is implemented for any
interesting class of rings in Sage. According to
   sage: search_def("unit_group")
there is only one method called "unit_group", which is for number
fields. Rather strange for me, because the algebraic notion of a unit
group is not very interesting for a *field*! But perhaps the number
theorists have a different notion---which one are you talking about?

Anyway.

Looking at the example of the "unit_group" method, I get this:
        sage: x = QQ['x'].0
        sage: A = x^4 - 10*x^3 + 20*5*x^2 - 15*5^2*x + 11*5^3
        sage: K.<a> = NumberField(A)
        sage: U = K.unit_group()
        sage: U(a)
        Traceback (most recent call last)
        ...
        ValueError: a is not a unit
        sage: ~a
        -1/1375*a^3 + 2/275*a^2 - 4/55*a + 3/11

Hence, if we talk about the algebraic notion of a unit of the ring K,
the above is wrong. However, it seems that the unit group of a number
field is meant to be the unit group of the ring of integers of the
number field. So, let's try again:

        sage: R = K.ring_of_integers()
        sage: while 1:
        ....:     u = R.random_element()
        ....:     if u != 0 and ~u in R:
        ....:         break
        ....:     
        sage: u
        1
        sage: U(u)
        1

More interesting example:

        sage: U.gens_values()
        [-7/275*a^3 + 1/11*a^2 - 9/11*a - 1, 7/275*a^3 - 1/11*a^2 +
        9/11*a + 2]
        sage: u = (7/275*a^3 - 1/11*a^2 + 9/11*a + 2)^2
        sage: u
        13/275*a^3 - 14/55*a^2 + 23/11*a - 1
        sage: u.parent()
        Number Field in a with defining polynomial x^4 - 10*x^3 +
        100*x^2 - 375*x + 1375
        sage: U(u)
        u1^2
        sage: _.parent()
        Unit group with structure C10 x Z of Number Field in a with
        defining polynomial x^4 - 10*x^3 + 100*x^2 - 375*x + 1375

So, in summary, the usual conversion syntax should just work.

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to