Opened 5 years ago
Closed 8 months ago
#20288 closed defect (duplicate)
Arithmetic in QQbar mutates elements
Reported by: | jdemeyer | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | sage-duplicate/invalid/wontfix |
Component: | number theory | Keywords: | |
Cc: | vdelecroix | Merged in: | |
Authors: | Reviewers: | Markus Wageringel | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
When doing arithmetic with a QQbar
element, operations subtly mutate the elements which should be constant.
In the example below, we see that M^2
is displayed differently after we compute the rank of M
:
sage: M = matrix(QQbar, 2, 2, [1, sqrt(-3), -sqrt(-3), 3]) sage: M^2 [ 4.000000000000000? 6.928203230275509?*I] [-6.928203230275509?*I 12.00000000000000?] sage: rank(M) 1 sage: M^2 [ 4 6.928203230275509?*I] [-6.928203230275509?*I 12]
One can easily see the difference in the __dict__
of the upper right element:
sage: M = matrix(QQbar, 2, 2, [1, sqrt(-3), -sqrt(-3), 3]) sage: M[0,1].__dict__ {'_descr': Root 1.7320508075688772935?*I of x^2 + 3, '_value': 1.7320508075688772935?*I} sage: rank(M) 1 sage: M[0,1].__dict__ {'_descr': -2*a + 1 where a^2 - a + 1 = 0 and a in 0.50000000000000000? - 0.866025403784439?*I, '_value': 1.73205080756887729352744634150587236694?*I}
Change History (7)
comment:1 Changed 5 years ago by
- Description modified (diff)
comment:2 Changed 5 years ago by
comment:3 follow-up: ↓ 4 Changed 5 years ago by
I agree that it's not a major problem. But I did find it confusing.
You think that we should have a string representation that is independent of what is known about the number?
That would of course be better, but I don't know how feasible that is.
comment:4 in reply to: ↑ 3 Changed 5 years ago by
Replying to jdemeyer:
I agree that it's not a major problem. But I did find it confusing.
You think that we should have a string representation that is independent of what is known about the number?
That would of course be better, but I don't know how feasible that is.
Look at the method interval_exact
: exactification will occur only when the number looks like an exact float. Though, using this approach will change representations of elements in QQ
. And without exactification, we have no way to detect rationality...
comment:5 Changed 8 months ago by
- Milestone changed from sage-7.2 to sage-duplicate/invalid/wontfix
- Status changed from new to needs_review
Works as intended, we should close it as "wontfix".
comment:6 Changed 8 months ago by
- Reviewers set to Markus Wageringel
- Status changed from needs_review to positive_review
This is a duplicate of #25458.
comment:7 Changed 8 months ago by
- Resolution set to duplicate
- Status changed from positive_review to closed
Simpler example
But what is wrong with it? It is just a change in the display? You think that we should have a string representation that is independent of what is known about the number?