The following leads to a TypeError:sage: K2.<sqrt2> = QuadraticField(2)
sage: K3.<sqrt3> = QuadraticField(3)
sage: sqrt2 + sqrt3
Both of them are real embedded by default, so coercion should work (at least this is my opinion).
This can be fixed by specifying that both of them are embedded into the algebraic reals (at the moment RLF is default).
Also casting sqrt2 to AA does not work at the moment (at least not without numerical noise).
Is it reasonable to apply this by default (i.e. embed quadratic fields into AA/QQbar)?
This would lead to failing doctests for mostly two reasons:
The following leads to a TypeError:sage: K2.<sqrt2> = QuadraticField(2)
sage: K3.<sqrt3> = QuadraticField(3)
sage: sqrt2 + sqrt3
Both of them are real embedded by default, so coercion should work (at least this is my opinion).
This can be fixed by specifying that both of them are embedded into the algebraic reals (at the moment RLF is default).
On Friday, November 29, 2019 at 12:45:45 PM UTC-8, Jonathan Kliem wrote:The following leads to a TypeError:sage: K2.<sqrt2> = QuadraticField(2)
sage: K3.<sqrt3> = QuadraticField(3)
sage: sqrt2 + sqrt3
Both of them are real embedded by default, so coercion should work (at least this is my opinion).
This can be fixed by specifying that both of them are embedded into the algebraic reals (at the moment RLF is default).Embedding into RLF is really meant to be "embedding into real floats, with yet-to-be-specified precision". Float arithmetic has very different properties from AA/QQbar: it's reliably quick, but imprecise and with no equality test., whereas AA/QQbar is unpredictable in computation speed and possibly VERY expensive (but reliable) equality test.
I don't know if the choice of RLF was appropriate for a default embedding, but I'd be wary of embedding in AA/QQbar by default, because they are so unpredictable in their performance. Generally, you should NOT be computing in them except for exploratory work. It's usually possible to be more specific about the desired field with a bit of analysis and then you'll get much better and reliable performance.
I don't know if the choice of RLF was appropriate for a default embedding, but I'd be wary of embedding in AA/QQbar by default, because they are so unpredictable in their performance. Generally, you should NOT be computing in them except for exploratory work. It's usually possible to be more specific about the desired field with a bit of analysis and then you'll get much better and reliable performance.So is the current setup is meant to tell the user to think and figure out a good conversion him/herself?
I mean there is composite field and one can always convert to that and work there.
Still conversion to AA and QQbar should work without numerical noise. But that is a different topic.
Calling c.minpoly() triggers some exactification. Compare with
sage: a = AA(2).sqrt()
sage: b = AA(3).sqrt()
sage: (a + b) * (a - b) * (b - a) * (-a -b)
1.000000000000000?
Who do I have to make a campaign donation to if I want this to be the
default?