In general number fields have many absolute values, one for each embedding
into CC or RR or p-adic Qp.  So, for z.abs() to be well defined someone
must have decided on a default embedding, and in Sage this is only done (as
far as I know) for quadratic fiellds , real and complex, and for cyclotomic
fields.  Thanks to that default embedding each element of a cyclotomic
field can be treated as a complex number (mapping the standard generator to
exp(2*pi*i/n) and not to any  other primitive n'th root of unity).  That's
what you are getting when you ask for z.abs().

You are right that one could ask for this to be returned as an algebraic
number.  The field is Galois and its Galois group has a distinguished
element matching complex conjugation, the one taking the generator z to
1/z.  Hence one can talk about the "complex conjugate" of any element.
This is implemented as z.conjugate() and returns an element of the same
cyclotomic field.  Then the product z*z.conjufate() is well-defined as an
element of the field, which happens to lie in the real subfield.  The
positive square root of that is then again algebraic but lies in a number
field not yet in play, and depending on the element whose abs you want.

Personally I cannot think of a reason why one would want this abs() to be
returned as an algebraic number, since the whole point of absolute values
in algebraic number theory is that they like in some completion (RR, CC, Qp
or an extension of Qp).  One could try to special-case cyclotomic fields --
which makes sense *only* because they have an automorphism of order 2 which
can be identified with complex conjugation -- but a function whose return
values had a parent which depended on the input would surely not be useful.

If you want QQbar you can already do
sage: QQbar(z).abs()
1.000000000000000?

which despite appearances is exactly 1:

sage: az = QQbar(z).abs()
sage: az
1.000000000000000?
sage: az.exactify()
sage: az
1




On Thu, 25 Oct 2018 at 00:33, Volker Braun <vbraun.n...@gmail.com> wrote:

> On Wednesday, October 24, 2018 at 4:08:05 PM UTC+2, Daniel Krenn wrote:
>>
>> What is the reason, why this returns an inexact result and not something
>> in an exact ring like QQbar?
>
>
> Well abs() is real and positive, so QQbar might not be the first choice.
>
> Small orders are apparently special cased:
>
>
> sage: C3.<t> = CyclotomicField(3)
> sage: abs(t + t.conjugate())
> 1
> sage: C3.<t> = CyclotomicField(3)
> sage: abs(t - t.conjugate())        # here the output is in a number field
> sqrt3
> sage: parent(_)
> Number Field in sqrt3 with defining polynomial x^2 - 3
> sage: (t - t.conjugate()).abs()     # abs function and abs method return
> answers in different parent rings
> 1.73205080756888
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.
>

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

Reply via email to