On Tue, Sep 3, 2024 at 11:07 AM Oscar Benjamin <oscar.j.benja...@gmail.com> wrote: > > On Tue, 3 Sept 2024 at 09:09, Dima Pasechnik <dimp...@gmail.com> wrote: > > > > Would it be better to hold a vote to decide on the ways to deal with this > > issue, rather than on this particular PR? > > Namely, the alternatives are > > > > 1) do nothing > > 2) bring AA in line with Python > > 3) bring RR in line with AA > > What does it mean to bring RR in line with AA here? So that RR(-1)**(1/3)==-1, too.
> > There are different ways to extend exponentiation a^b if b is not > constrained to integer values but there is only really one natural way > in the case of real and complex numbers if it should be both > continuous and single-valued. For real a and b with positive a we can > say that a^b = exp(b*log(a)). As long as you require a>0 this is > consistent with the ways that you would naturally define the operation > for integer or rational b or with a being in any subfield of the > reals. the point is different - on the reals the function x->x^(1/3) is 1-1. 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. > > The same definition a^b = exp(b*log(a)) extends to all complex numbers > if you choose a branch convention for log and then you can allow a to > be a negative number or generally any nonzero complex number. These > two definitions of exponentiation for real and for complex numbers are > consistent and are continuous in both a and b except at the branch > cuts. > > The idea that for negative a and rational b you can say that a^b gives > a real root if the denominator of b is odd does not extend in any way > to a continuous function of b in either the reals or complex numbers. > Since RR is approximate it is not possible to implement an operation > like a^b coherently if the definition is not continuous in both a and > b. > > To put this another way: you might want RR(-1)^(1/3) to be real but > you certainly don't want RR(-1)^(1/2) to be real. If the exponent in > a^b is an element of RR then you would need to distinguish whether it > has an even or an odd denominator to be able to say whether the root > is real or imaginary. Every non-integer element of RR literally has an > even denominator though: > > >>> RR(1/3).sign_mantissa_exponent() > (1, 6004799503160661, -54) > >>> 6004799503160661 / 2**54 > 0.3333333333333333 > > Defining a^b for RR so that (-1)^(1/3) = -1 could only work if b was > restricted to the rationals so that the exponent cannot be an element > of RR. For AA the exponent is restricted to the rationals: > > >>> AA(4)^(1/2) > 2 > >>> AA(4)^AA(1/2) > TypeError: unsupported operand parent(s) for ^: > 'Algebraic Real Field' and 'Algebraic Real Field' > > -- > Oscar > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/sage-devel/CAHVvXxSfnmMhcP9esrXHEZKeMi_3qwm6%3DtKkJn0JzCNN5wN%3DiA%40mail.gmail.com. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAAWYfq3HbLgJj%3DPDz227dRjQsD4LfwfaHN35F7taLOW0oeZ09w%40mail.gmail.com.