Opened 5 years ago
Last modified 2 years ago
#15854 needs_work defect
series of x^s, when s is symbolic
Reported by: | dkrenn | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-6.4 |
Component: | symbolics | Keywords: | symbolic, series, exponent |
Cc: | mforets | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
We have the following behaviour:
sage: var('s') s sage: (x^s).series(x, 0) Order(1) sage: (x^s).series(x, 1) (0^s) + Order(x) sage: (x^s).series(x, 2) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-4-5abc79662303> in <module>() ----> 1 (x**s).series(x, Integer(2)) /usr/opt/sage-6.1.1/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.series (sage/symbolic/expression.cpp:17596)() ValueError: power::eval(): division by zero
This output is weird and definitely wrong (since the correct output depends strongly on s
.).
Change History (5)
comment:1 Changed 5 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:2 Changed 5 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:3 Changed 4 years ago by
comment:4 Changed 4 years ago by
- Status changed from new to needs_info
Could you please specify what output exactly to expect?
comment:5 Changed 2 years ago by
- Cc mforets added
- Status changed from needs_info to needs_work
there is no error if you declare s
as integer:
sage: s = SR.var('s', domain='integer') sage: (x^s).series(x, 2) # ok (?) or we expect x^s (0^s) + (0^(s - 1)*s)*x + Order(x^2)
to compare, W|A gives various series representations. in this case maybe it could answer just x^s
?
however, there is this closely related issue:
sage: n = SR.var('n', domain='integer') sage: ((x+1/x)**n).series(x) # wrong (what happened with n?) 1 + Order(x^20)
one expects something like 1/x^n*(1 + n*x^2 + O(x^3))
.
this behaviour has side effects for example if you want to compute the residue of this function:
sage: f = 1/x*((x^2+1)/(2*x))**(2*k) sage: f.residue(x==0) # wrong (1/2)^(2*k)
in fact:
sage: f(k=4) 1/256*(x^2 + 1)^8/x^9 sage: f(k=4).residue(x==0) 35/128 sage: f.residue(x==0).subs(k==4) 1/256 sage: res(k) = 1/2**(2*k)*binomial(2*k, k) # correct answer sage: res(k=4) 35/128
a bit unrelated, but let me mention that SymPy?'s residue
gives wrong result for this one (0), and giac gives unevaluated expression.
Still there in 6.6