Opened 8 years ago
Last modified 5 years ago
#13097 new defect
integral of ln(1+4/5*sin(x)) from -3.1415 to 3.1415 crashes Maxima and Sage
Reported by: | kcrisman | Owned by: | burcin |
---|---|---|---|
Priority: | major | Milestone: | sage-6.4 |
Component: | calculus | Keywords: | |
Cc: | benjaminfjones, dsm | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | Fixed upstream, but not in a stable release. | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
See extensive discussion at this sage-support thread.
Reported by Ben Jones:
sage: integrate(ln(1+4/5*sin(x)), x, -3.1415, 3.1415) ;;; ;;; Binding stack overflow. ;;; Jumping to the outermost toplevel prompt ;;; ... ;;; ;;; Binding stack overflow. ;;; Jumping to the outermost toplevel prompt ;;; /Users/jonesbe/sage/sage-5.1.beta2/spkg/bin/sage: line 335: 86594 Illegal instruction sage-ipython "$@" -i
There don't seem to be any problems with Maxima. Although it's been traced down (thanks to Dan Drake) to 5.0.beta3, the only obvious candidate for a change in our interface is when we added abs_integrate
, which doesn't seem to impact things.
(%i2) load(abs_integrate); (%o2) /Users/.../sage-5.0/local/share/maxima/5.26.0/s\ hare/contrib/integration/abs_integrate.mac (%i4) keepfloat:true; (%o4) true (%i7) integrate(ln(1+4/5*sin(x)), x, -3.1415, 3.1415); 3.1415 / [ 4 sin(x) (%o7) I ln(-------- + 1) dx ] 5 / - 3.1415
And we have
sage: maxima_calculus(" integrate(ln(1+4/5*sin(x)), x, -3.1415, 3.1415);") 'integrate(ln(4*sin(x)/5+1),x,-3.1415,3.1415)
so something must indeed be wrong in how we're sending this to Maxima.
Change History (14)
comment:1 Changed 8 years ago by
- Cc benjaminfjones added
- Description modified (diff)
comment:2 Changed 8 years ago by
comment:3 Changed 8 years ago by
- Cc dsm added
comment:4 follow-ups: ↓ 6 ↓ 7 Changed 8 years ago by
I don't think maxima understands ln
. If you do
maxima_calculus(" integrate(log(1+4/5*sin(x)), x, -3.1415, 3.1415);")
you see the same thing happening. No problem in vanilla maxima. But when we load abs_integrate
:
(%i1) load(abs_integrate); (%o1) /usr/local/sage/5.0/local/share/maxima/5.26.0/share/contrib/integration/abs_integrate.mac (%i2) integrate(log(1+4/5*sin(x)), x, -3.1415, 3.1415); ... Condition of type: STACK-OVERFLOW BINDING-STACK overflow at size 8448. Stack can probably be resized.
FYI: with
from sage.interfaces.maxima_lib import * from sage.libs.ecl import * args=(ln(1+4/5*sin(x)), x, -3.1415, 3.1415) I=EclObject(([max_integrate],[sr_to_max(SR(a)) for a in args])) I
you see what expression gets passed to maxima_lib. With
EclObject('#$integrate(log(1+4/5*sin(x)), x, -3.1415, 3.1415)$')
you see what maxima's parser would produce. With
maxima_eval(I)
you can trigger the same explosion. Note that with this trick, you can quickly see that
EclObject('#$integrate(ln(1+4/5*sin(x)), x, -3.1415, 3.1415)$')
creates an essentially different expression.
comment:5 Changed 8 years ago by
- Report Upstream changed from N/A to Reported upstream. No feedback yet.
The problem can be simplified to
integrate(log(sin(x)),x);
which maxima without abs_integrate
can do (or at least it returns an answer).
This is now Maxima Artifact 3533723
comment:6 in reply to: ↑ 4 Changed 8 years ago by
I don't think maxima understands
ln
. If you do
Well, egg on my face! Sorry for that noise. I just don't use Maxima enough beyond trying to generate bug reports or find new functionality for Sage :)
And good diagnosis; I guess if I had tried log
instead I would have gotten the same problem.
comment:7 in reply to: ↑ 4 Changed 8 years ago by
Replying to nbruin:
I don't think maxima understands
ln
.
*facepalm*. Sorry for noise on sage-support
comment:8 Changed 8 years ago by
- Report Upstream changed from Reported upstream. No feedback yet. to Reported upstream. Developers acknowledge bug.
We really need more options for "upstream" ;-). How about "Developers acknowledge bug, propose fix, but haven't gotten around to merging it because they got the fix with less than 24 hours round trip time"? See Maxima tracker. I have no doubt this will be fixed in some future Maxima release.
comment:9 Changed 8 years ago by
We can monkey-patch Barton Willis's fix into sage's maxima:
sage: L="""signum_int(q,x) := ....: block([w : 1, acc : [], sgn, v, f, listconstvars : true], ....: q : convert_to_signum(q), ....: if freeof('signum, q) then ....: (false) ....: else ( ....: q : almost_everywhere_simp(q), ....: v : listofvars(q), ....: q : block([expandwrt_denom : true], expandwrt(q,'signum)), ....: if (f : abs_int_extra(q,x)) # false then f ....: else if (f : partition_as_signum(q,x)) # false then ( ....: w : first(f), ....: acc : second(f), ....: if every(lambda([s], linear_in_p(s,x)), acc) then ( ....: sgn : xreduce("*", map(lambda([s], diff(s,x)),acc)), ....: acc : map(lambda([s], rhs(first(linsolve(s, x)))),acc), ....: signum_int_helper(signum(sgn) * w, sort(acc), x))) ....: else if (safe_op(q) = "+") then ( ....: f : map(lambda([s], signum_int(s,x)), args(q)), ....: if member(false, f) then false else xreduce("+", f)) ....: else block([extra_integration_methods : [], ....: extra_definite_integration_methods : []],integrate(q,x)) ....: ) ....: );""" sage: integrate(ln(1+4/5*sin(x)), x, -3.1415, 3.1415) integrate(log(4/5*sin(x) + 1), x, -3.1415, 3.1415) sage: integrate(ln(sin(x)),x) 1/2*I*x^2 - 1/2*x*log(sin(x)^2 + cos(x)^2 - 2*cos(x) + 1) - 1/2*x*log(sin(x)^2 + cos(x)^2 + 2*cos(x) + 1) + x*log(sin(x)) + I*x*arctan2(sin(x), -cos(x) + 1) - I*x*arctan2(sin(x), cos(x) + 1) + I*polylog(2, -e^(I*x)) + I*polylog(2, e^(I*x))
This just patches a routine defined in abs_integrate.mac
. It's a *LOT* slower than in 4.7.1, though, so if performance is any concern, we might want to reconsider whether abs_integrate should be loaded by default. By manipulating the maxima variables extra_integration_methods
and extra_definite_integration_methods
it should be possible to control which integration methods maxima tries to use (this is what abs_integrate
hooks into).
comment:10 Changed 7 years ago by
- Report Upstream changed from Reported upstream. Developers acknowledge bug. to Fixed upstream, but not in a stable release.
comment:11 Changed 6 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:12 Changed 6 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:13 Changed 6 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:14 Changed 5 years ago by
- Milestone changed from sage-6.3 to sage-6.4
Could it rather be something wrong in how we are receiving data from Maxima(lib)?