Opened 3 years ago
Last modified 7 months ago
#20824 needs_review enhancement
Add Expression.coefficient(...expand=True) keyword
Reported by:  rws  Owned by:  

Priority:  major  Milestone:  sage8.2 
Component:  symbolics  Keywords:  
Cc:  Merged in:  
Authors:  Ralf Stephan  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  u/rws/20824 (Commits)  Commit:  7ab049f6e36a201ca98ad482c3c0a2d48227d614 
Dependencies:  Stopgaps: 
Description (last modified by )
There is no reason why there should be different results:
sage: (x*(x*y+y^2)).coefficient(x) y sage: (x*(x*y+y^2)).coefficient(x,2) 0 sage: (x*(x*y+y^2)).expand().coefficient(x) y^2 sage: (x*(x*y+y^2)).expand().coefficient(x,2) y
This would also be unsurprising for Mma users, see http://trac.sagemath.org/ticket/9505#comment:6
Maybe add keyword expand=True
.
Change History (10)
comment:1 Changed 3 years ago by
 Description modified (diff)
 Summary changed from Expression.coefficient() should expand beforehand to Expression.coefficient() problems
comment:2 Changed 3 years ago by
 Description modified (diff)
comment:3 Changed 3 years ago by
 Description modified (diff)
comment:4 Changed 3 years ago by
 Branch set to u/rws/expression_coefficient___problems
comment:5 Changed 3 years ago by
 Commit set to a45909c72aa8d561337be41a85d930f5797ccd5e
 Milestone changed from sage7.3 to sage7.4
 Status changed from new to needs_review
 Summary changed from Expression.coefficient() problems to Add Expression.coefficient(...expand=True) keyword
 Type changed from defect to enhancement
comment:6 Changed 2 years ago by
Hmm, I don't really see the benefit compared to expr.expand().coefficient(...)
...
comment:7 Changed 16 months ago by
 Commit changed from a45909c72aa8d561337be41a85d930f5797ccd5e to 1d6fc68cbbb9515fde79799a13d5012e0036105a
Branch pushed to git repo; I updated commit sha1. New commits:
1d6fc68  Merge branch 'develop' into t/20824/expression_coefficient___problems

comment:8 Changed 12 months ago by
 Branch changed from u/rws/expression_coefficient___problems to u/rws/20824
comment:9 Changed 12 months ago by
 Commit changed from 1d6fc68cbbb9515fde79799a13d5012e0036105a to 7ab049f6e36a201ca98ad482c3c0a2d48227d614
 Milestone changed from sage7.4 to sage8.2
New commits:
7ab049f  20824 Add Expression.coefficient(...expand=True) keyword

comment:10 Changed 7 months ago by
I had a look at the patch:
 It looks like
r
is assigned in thetry
block but then not returned or called afterwards. Is this necessary? (I haven't completely digested the pynac interface so I may be missing something, but this looks strange...)  Should this be added to
coefficients
as well?  The indentation to
TESTS:
in the docstring was changed accidentally.
Note: See
TracTickets for help on using
tickets.
New commits:
20824: add Expression.coefficient(...expand=True) keyword