Admittedly, the author of this thread did not consider the case in the
list of targets but when comparing 'conjugate' to 'imag_part' in Sage
I was surprized to see the following results.

##
Advertising

sage: Q.<i,j,k> = QuaternionAlgebra(SR, -1, -1)
sage: a,b,c=var('a,b,c')
sage: q = x + a*i + b*j + c*k
sage: conjugate(q)
x + (-a)*i + (-b)*j + (-c)*k
That's OK but
sage: SR(q).imag_part()
0
sage: bool(q/2+conjugate(q)/2==q)
True
sage: bool(x==q)
True
sage: x==q
True
It seems to me that these are all incorrect. I am not sure exactly
what the coercion to SR is supposed to do in this case. It also does
not make sense to me that the last equality returns True.
On 20 September 2016 at 16:29, Emmanuel Charpentier
<emanuel.charpent...@gmail.com> wrote:
>
>
> Le mardi 20 septembre 2016 04:02:16 UTC+2, Bill Page a écrit :
>>
>> In keeping with Richard's suggestion, in Sage I think a good
>> _algebraic_ definition of 'real' is
>>
>> bool(x/2+conjugate(x)/2 == x)
>
>
> why not bool(SR(x).imag_part()==0) ?
>>
>>
>> So
>>
>> sage: def RN(x):
>> ....: try:
>> ....: return bool(x/2+conjugate(x)/2 == x)
>> ....: except:
>> ....: return false
>>
>> which also works whenever conjugate is defined, including
>>
>> sage: assume(x,'real')
>> sage: assume(y,'real')
>> sage: RN(sqrt(x^2+y^2))
>> True
>>
--
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.