Opened 11 years ago
Closed 3 years ago
#7589 closed defect (fixed)
bug in coercion and cyclotomic fields
Reported by: | AlexGhitza | Owned by: | robertwb |
---|---|---|---|
Priority: | major | Milestone: | sage-8.3 |
Component: | coercion | Keywords: | coercion, cyclotomic, coxeter |
Cc: | vripoll, stumpc5, tscrim | Merged in: | |
Authors: | Frédéric Chapoton | Reviewers: | Travis Scrimshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | 0a00b44 (Commits, GitHub, GitLab) | Commit: | 0a00b44d43002eaf650a418b516a838cb32f334f |
Dependencies: | Stopgaps: |
Description
This should work automagically:
---------------------------------------------------------------------- | Sage Version 4.2.1, Release Date: 2009-11-14 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: a = CyclotomicField(3).random_element() sage: b = CyclotomicField(4).random_element() sage: a + b --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/ghitza/.sage/temp/artin/9098/_home_ghitza__sage_init_sage_0.py in <module>() /home/ghitza/sage-devel/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.ModuleElement.__add__ (sage/structure/element.c:6989)() /home/ghitza/sage-devel/local/lib/python2.6/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:7021)() TypeError: unsupported operand parent(s) for '+': 'Cyclotomic Field of order 3 and degree 2' and 'Cyclotomic Field of order 4 and degree 2' sage: a * b --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/ghitza/.sage/temp/artin/9098/_home_ghitza__sage_init_sage_0.py in <module>() /home/ghitza/sage-devel/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.RingElement.__mul__ (sage/structure/element.c:10248)() /home/ghitza/sage-devel/local/lib/python2.6/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:7021)() TypeError: unsupported operand parent(s) for '*': 'Cyclotomic Field of order 3 and degree 2' and 'Cyclotomic Field of order 4 and degree 2'
I think it's a coercion problem. If someone knows better, please change the trac component accordingly.
Change History (13)
comment:1 Changed 8 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:2 Changed 7 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:3 Changed 7 years ago by
comment:4 Changed 7 years ago by
- Keywords coercion cyclotomic added
comment:5 Changed 7 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:6 Changed 7 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:7 Changed 6 years ago by
- Cc vripoll added
comment:8 Changed 5 years ago by
- Milestone changed from sage-6.4 to sage-7.4
see also the somehow related #20746
comment:9 Changed 3 years ago by
- Branch set to u/chapoton/7589
- Cc stumpc5 added
- Commit set to 0a00b44d43002eaf650a418b516a838cb32f334f
- Keywords coxeter added
- Milestone changed from sage-7.4 to sage-8.3
- Status changed from new to needs_review
comment:10 Changed 3 years ago by
You should take care of embeddings. The map add: CF(p) x CF(q) -> CF(lcm(p,q))
is not uniquely defined.
comment:11 Changed 3 years ago by
- Cc tscrim added
Well. What we just add here is the information that we need to go through CF(lcm). No responsability is taken on the existence of a canonical coercion from CF(p) to CF(lcm). I guess that this already an existing thing..
comment:12 Changed 3 years ago by
- Reviewers set to Travis Scrimshaw
- Status changed from needs_review to positive_review
As Frederic said, this does not change the (canonical) coercions between cyclotomic fields but allows the analogous computation to
sage: R.<x,y> = ZZ[] sage: S.<y> = QQ[] sage: R.an_element() + S.an_element() x + y sage: _.parent() Multivariate Polynomial Ring in x, y over Rational Field
comment:13 Changed 3 years ago by
- Branch changed from u/chapoton/7589 to 0a00b44d43002eaf650a418b516a838cb32f334f
- Resolution set to fixed
- Status changed from positive_review to closed
Has anyone looked at this ticket? I ran into this today and discover that the issue has been reported 4 years ago... This bug is particularly confusing for the user, especially when you read the doc that says "Due to their default embedding into CC, cyclotomic number fields are all compatible", and goes on to show the following example:
It turns out Sage is able to compute that only because the first field contains the next two! Note the following test: