This is indeed annoying. For further input, notice that python gives
the complex principal root rather than the real root
>>> (-1.) ** 0.33
(0.5090414157503712+0.8607420270039436j)
I think it is of doubtful correctness RR not being closed under coercion:
sage: RR(RR(-1)^(1/3))
TypeError: unable to convert '0.500000000000000+0.866025403784439*I'
to a real number
> >>> (-1)**(1/3)
> (0.5000000000000001+0.8660254037844386j)
Your example illustrates twice that an operation can lead to a bigger
set : 1/3 is a python float :-)
It is puzzling, but it does not seem to be so.If 1/3 would be a python float, (-1)**(1/3) is not defined under the usual definition of x^y = exp(y*ln(x)) with the standard branch cut for the logarithmic function.
Surely the output of -1 for AA(-1)^(1/3) is correct: AA is the "Algebraic Real Field" and -1 has exactly one cube root in there, namely itself. On the other hand, QQbar(-1) has 3 cube roots and one is chosen (in some deterministic way).I do not think that AA(-1)^(1/3) should return a cubroot in another field/parent when there is one in the same field/parent. Comparesage: QQ(-1).nth_root(3)
-1
sage: RR(-1).nth_root(3)
-1.00000000000000
sage: CC(-1).nth_root(3)
0.500000000000000 + 0.866025403784439*Iwhich is as it should be (in my opinion!)
I agree that there should be an internal nth root method,
If anyone has objections, please state them in #38362.
Secondly, I am very unhappy as a user with the following
sage: AA((-1)**(1/3))
-1
sage: QQbar((-1)**(1/3))
0.500000000000000? + 0.866025403784439?*I
Let me mention that this question of powering is intimately related to
the question whether the powering operator should be part of the
coercion model. This has been done by Jeroen Demeyer years ago in 2017
(see https://github.com/sagemath/sage/issues/24247). Unless we revert
this, the parent of a**b should only depend on parent(a) and parent(b)
(whatever values have a and b).
That in Python one has non-real value for (-1)**(1/3) is
two things: 1/3 is actually a float, and absence of typing.
These are artifacts of the programming language, and make little sense
mathematically.
I think that only valid argument for AA(-1)^(1/3) = -1 is that it is the status quo. It is just human that likes what she/he used to. Removing inconsistency is for the future.
On Tuesday 3 September 2024 at 19:44:43 UTC-7 Kwankyu Lee wrote:I think that only valid argument for AA(-1)^(1/3) = -1 is that it is the status quo. It is just human that likes what she/he used to. Removing inconsistency is for the future.The fact that powers with odd denominator do not leave AA is also a documented design decision:
... I'd add as a valid argument for the branch choice in AA that it makes sense to choose a branch that does *not* require an extension of the parent, if possible. Yes, it's a different branch choice than the one made in Qbar, but AA and Qbar are different objects, with AA coercible into Qbar.
If you mean "branch choice" in mathematical sense, the branch choice of Qbar (and CC and RR)ln(z) = ln(r) + i * theta for z = r * exp(i * theta) with r > 0, -pi < theta <= pi(note <= at the end) is most natural for maximal continuity. I think this is more mathematical than choosing a "branch" that "does not require an extension of the parent".
.. Indeed, Magma's algebraic closure of QQ does not use an embedding into CC but instead tracks conjugate labels using a large finite field.
--
You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/s81ieq2vpVo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/afb486c5-7efb-4b6c-94f9-dc230a1108fen%40googlegroups.com.
Indeed, Magma's AlgebraicallyClosedField is not embedded into CC; it also has no version of AA. And Nils meant what he said about large *finite* fields being used to keep track. I find QQbar easier to use -- but when Magma's AlgebraicallyClosedField was first developed it was a really original idea and state of the art, there is at least one paper describing how it works (Nils, I cannot remember the author -- is it Allan Steele?).
... it may well depend on whether you're more algebraically or analytically oriented.
>>> RR(ZZ(-8)^(1/3))
...
TypeError: unable to convert '1.00000000000000+1.73205080756888*I'
to a real number
This coercion also seems questionable:
>>> parent(ZZ(8)^(1/3))
Rational Field
exponentiation should not use a general coercion and the type of the
exponent should be treated differently from the type of the base.
>Now back in sage, sage chose to be compatible with python's behavior in
>x^(1/3) for whatever x that represents a number in the complex field, say x
>= -1, RR(-1), CC(-1), QQbar(-1). For x = ZZ(-1), QQ(-1), they chose to
>return symbolic expression (-1)^(1/3), which again converted to the same
>value with QQbar(-1)^(1/3). For x = RBF(-1), it chose to raise an error.
>For x = RDF(-1), it chose to return "nan". All these suggest to sage users
>that x^(1/3) means the principal cube root of the number x.
For mathematicians who do real algebra and real algebraic geometry, it's extremely unfortunate when
reality is not respected by functions which, mathematically, can respect reality.