-
-
Notifications
You must be signed in to change notification settings - Fork 564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
number_field_elements_from_algebraics incorrectly simplify root of unity? #36735
Comments
Looks like a bug indeed. You could avoid using the symbolic ring:
|
I think these are the source of the erroneous answer:
Shouldn't they give an error, instead of converting? |
Sorry, I removed the |
I think this is the problem: In lines 105-110 of the method |
Since sage: QQbar((-1)^(1/3))
0.500000000000000? + 0.866025403784439?*I
sage: QQbar(E(3))
-0.500000000000000? + 0.866025403784439?*I
sage: QQbar((-1)^(2/3))
-0.500000000000000? + 0.866025403784439?*I
sage: QQbar(E(3)**2)
-0.500000000000000? - 0.866025403784439?*I
sage: L, [ww], phi = number_field_elements_from_algebraics([QQbar((-1)^(2/3))])
sage: L
Cyclotomic Field of order 6 and degree 2
sage: ww
zeta6 - 1
sage: phi
Ring morphism:
From: Cyclotomic Field of order 6 and degree 2
To: Algebraic Field
Defn: zeta6 |--> 0.500000000000000? + 0.866025403784439?*I |
sagemathgh-38606: number_field_elements_from_algebraics: Consistently use principal root Fixes sagemath#36735 . Also this leads to performance improvement because we don't necessarily waste time convert the elements to algebraic twice. E.g. if the list of numbers is of the form `[x, y, z]` where `x, y` is a symbolic expression representing a real algebraic number and `z` is a symbolic expression representing a complex algebraic number, then we have to convert `x` and `y` first to `AA` and then to `QQbar`. This is wasted. With the new code it's only converted to `QQbar` once. I believe the conversion from `QQbar` to `AA` should be mostly free? I think we can all agree that the current behavior is a bug — the odd- degree root are either interpreted as real root or principal root depends on whether other complex element appear in the list: ```python sage: number_field_elements_from_algebraics([(-1)^(2/3), I]) # interpreted as principal root (Number Field in a with defining polynomial y^4 - y^2 + 1, [a^2 - 1, a^3], Ring morphism: From: Number Field in a with defining polynomial y^4 - y^2 + 1 To: Algebraic Field Defn: a |--> 0.866025403784439? + 0.500000000000000?*I) sage: number_field_elements_from_algebraics([(-1)^(2/3), 2]) # interpreted as real root (Rational Field, [1, 2], Ring morphism: From: Rational Field To: Algebraic Real Field Defn: 1 |--> 1) ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. (no change) URL: sagemath#38606 Reported by: user202729 Reviewer(s): Kwankyu Lee
Steps To Reproduce
Run
Expected Behavior
That ww become a primitive 3rd root of unity.
Actual Behavior
ww = 1.
Additional Information
No response
Environment
Checklist
The text was updated successfully, but these errors were encountered: