OK, this explanation seems to be reasonable. But maybe the site
https://doc.sagemath.org/html/en/tutorial/tour_rings.html
should be edited (adding "An approximation to the field of real numbers using floating point numbers with any specified precision"). Currently there is: "the real numbers, called RR in Sage". Ok, x is not a number but a variable. But it should be emphasized that in RR are only specific real numbers (convertible to floating point), not variables (representing any number).
This site may also be interesting for someone like me who is new to sagemath:
https://ask.sagemath.org/question/9950/what-are-the-different-real-numbers-in-sage/
To make it short, x belongs to RR if x is real AND a constant (or an expression that can be converted to a constant), or am I wrong ?
Now it's clear that
print(ZZ.is_exact())
print(QQ.is_exact())
print(RR.is_exact())
print(CC.is_exact())
gives:
True
True
False
False
Is there any ring - call it RING - that is like the real numbers used in mathematics, so that
x in RING
gives True then and only then if x.is_real() is true ? (Just for interest - I know that I can use is_real() and this should normally be good).
What may also be interesting, is: On some other site I found that sagemath cannot prove that
2*(cos(3/7*pi) - cos(2/7*pi) + cos(1/7*pi))-1
is exactly zero.
print((2*(cos(3/7*pi) - cos(2/7*pi) + cos(1/7*pi))-1).simplify_full())
print((2*(cos(3/7*pi) - cos(2/7*pi) + cos(1/7*pi))-1).n())
1 + I * (2*(cos(3/7*pi) - cos(2/7*pi) + cos(1/7*pi))-1) in RR
Output:
2*cos(3/7*pi) - 2*cos(2/7*pi) + 2*cos(1/7*pi) - 1
0.000000000000000
True
It seems that sagemath rounds the numerical approximation of the first expression exactly to zero and so it says that the imaginary part of the third expression is zero and so the expression is in RR. But I wouldn't see a problem if the answer was False - in case the approximation of the imaginary part would give some small nonzero number.