Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

is_real vs. in RR for variables

It seems that - if x is a variable that I assume to be real - that x in RR gives not the same as x.is_real() :

var("x y")
assume(x,"real")

print(bool(x in RR))      # should give True ???
print(x.is_real())

print(abs(y) in RR)       # should give True ???
print(abs(y).is_real())

print(pi in RR)
print(pi.is_real())

print(I in RR)
print(((I + y) - y).is_real())     # I must create some expression since I.is_real() gives an error

output:

False
True
False
True
True
True
False
False

I don't understand the first abs third output. I would expect TRUE for them since I was thinking that x in RR gives True is sagemath (can proove that) x is real.

Does anybody know why sagemath behaves like that ?

is_real vs. in RR for variables

It seems that - if x is a variable that I assume to be real - that x in RR gives not the same as x.is_real() :

var("x y")
assume(x,"real")

print(bool(x in RR))      # should give True ???
print(x.is_real())

print(abs(y) in RR)       # should give True ???
print(abs(y).is_real())

print(pi in RR)
print(pi.is_real())

print(I in RR)
print(((I + y) - y).is_real())     # I must create some expression since I.is_real() gives an error

output:

False
True
False
True
True
True
False
False

I don't understand the first abs third output. I would expect TRUE for them since I was thinking that x in RR gives True is sagemath (can proove that) x is real.

Does anybody know why sagemath behaves like that ?

is_real vs. in RR for variables

It seems that - if x is a variable that I assume to be real - that x in RR gives not the same as x.is_real() :

var("x y")
assume(x,"real")

print(bool(x in RR))      # should give True ???
print(x.is_real())

print(abs(y) in RR)       # should give True ???
print(abs(y).is_real())

print(pi in RR)
print(pi.is_real())

print(I in RR)
print(((I + y) - y).is_real())     # I must create some expression since I.is_real() gives an error

output:

False
True
False
True
True
True
False
False

I don't understand the first abs and third output. I would expect TRUE for them since I was thinking that x in RR gives True is if sagemath (can proove that) x is real.

Does anybody know why sagemath behaves like that ?