Opened 3 years ago
Closed 3 years ago
#22340 closed enhancement (fixed)
Coefficient of an AsymptoticExpansion
Reported by: | cheuberg | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-7.6 |
Component: | asymptotic expansions | Keywords: | |
Cc: | dkrenn, behackl | Merged in: | |
Authors: | Clemens Heuberger | Reviewers: | Daniel Krenn |
Report Upstream: | N/A | Work issues: | |
Branch: | f04154b (Commits) | Commit: | f04154b6f47d6510503e8fcc5af6e7b2bfd28269 |
Dependencies: | Stopgaps: |
Description
The following would be convenient:
sage: R.<m, n> = AsymptoticRing("m^QQ*n^QQ", ZZ) sage: ae = 1 + 42/n + 2/n/m + O(n^-2) sage: ae.monomial_coefficient(1/n) 42
The choice of the method name monomial_coefficient
is motivated by the homonymous method of multivariate polynomial rings.
Change History (10)
comment:1 Changed 3 years ago by
- Branch set to u/cheuberg/coefficient-asymptotic-expansion
comment:2 Changed 3 years ago by
- Commit set to 6242878592c4c313a14d94e531684004f75c301e
- Status changed from new to needs_review
comment:3 Changed 3 years ago by
- Reviewers set to Daniel Krenn
Looks good; I only have very small things to discuss:
1.
+ - ``monomial`` -- a monomial element which can be converted + into the parent of this element.
What about rephrasing this to the following, so that the technical term "parent" is avoided
a monomial element which can be converted into the asymptotic ring of this element
- Remove period after "element." above (convention in SageMath; not used in the asymptotic_ring file much...).
3.
+ raise ValueError("non-exact monomial") + raise ValueError("not a monomial")
Within the asymptotic ring module usually error messages include the element (in the above, the monimial), i.e.
raise ValueError('non-exact monimal {}'.format(monomial)) raise ValueError('{} not a monomial'.format(monomial))
(Maybe inserting "is" in the latter, but not sure.)
comment:4 Changed 3 years ago by
- The method in the multivariate polynomial ring returns
0
if the monomial is not in the polynomial. Here aKeyError
will be raised. If there is no reason against0
, I think the behavior should coincide.
comment:5 Changed 3 years ago by
- FYI, the following (undocumented) feature of a polynomial is present:
sage: P.<x,y> = ZZ[] sage: a=(1+2*x*y+3*x^2) sage: a[x*y] 2 sage: a[x^2] 3
So maybe __getitem__
should have this behavior as well...
comment:6 Changed 3 years ago by
- Commit changed from 6242878592c4c313a14d94e531684004f75c301e to f04154b6f47d6510503e8fcc5af6e7b2bfd28269
comment:7 follow-up: ↓ 8 Changed 3 years ago by
1.-4. done
- I am not convinced: If this is not a documented and tested behaviour of polynomial rings, I am slightly hesitant to introduce this here. I am not against the concept, but IMHO it should be done in the polynomial ring first (and not on this ticket).
comment:8 in reply to: ↑ 7 Changed 3 years ago by
Replying to cheuberg:
1.-4. done
Thank you.
- I am not convinced: If this is not a documented and tested behaviour of polynomial rings, I am slightly hesitant to introduce this here. I am not against the concept, but IMHO it should be done in the polynomial ring first (and not on this ticket).
Fine for me not to do this now.
Patch LGTM; positive_review modulo non-finished patchbot
comment:9 Changed 3 years ago by
- Status changed from needs_review to positive_review
Two patchbot tested this ticket now; each timed out on a single, but different doctest, and these tests are not related to this ticket. Thus I set it to positive review
comment:10 Changed 3 years ago by
- Branch changed from u/cheuberg/coefficient-asymptotic-expansion to f04154b6f47d6510503e8fcc5af6e7b2bfd28269
- Resolution set to fixed
- Status changed from positive_review to closed
New commits:
Trac #22340: Coefficient of an AsymptoticExpansion