Ask Your Question
0

C-STACK overflow during integration

asked 2020-03-29 07:11:49 +0200

dreycenfoiles gravatar image

I am trying to run the following chunk of code

i = a*(1 + exp(-(b*x)^2/4)*cos(c*x)*cos(d*x))
i0 = i.subs(x=0)
W = 2*i - i0
G = integrate(W*exp(-I*k*x),(x,-oo,oo),algorithm="fricas").full_simplify()

with a,b,c,d,k,x being variables. When I do, I get the error

TypeError: ECL says: C-STACK overflow at size 1048576. Stack can probably be resized. Proceed with caution

The interesting thing is that when I have

 i = a*(1 + exp(-b*x^2/4)*cos(c*x)*cos(d*x))

and everything else the same, the integral can be performed. I was wondering either how to resize the stack as the error message suggests or how to fix the overflow?

Thank you for your time

edit retag flag offensive close merge delete

Comments

As a side note: the error is one that can come from "maximalib", so it doesn't seem like your option algorithm="fricas" is working. The C-stack overflow is probably an infinite recursion that probably happens in maxima itself as well (if the options are set in the same way as sage does). That would be reportable to maxima.

nbruin gravatar imagenbruin ( 2020-03-29 19:50:09 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-29 18:04:46 +0200

vdelecroix gravatar image

In this example it helps if you say that your parameters are positive real numbers (are they?)

sage: a,b,c,d,x,k = SR.var('a,b,c,d,x,k')
sage: i = a*(1 + exp(-(b*x)^2/4)*cos(c*x)*cos(d*x))
sage: i0 = i.subs(x=0)
sage: W = 2*i - i0
sage: for v in [a,b,c,d]:
....:     assume(v, 'real')
....:     assume(v > 0)
sage: integrate(W*exp(-I*k*x),(x,-oo,oo))
sqrt(pi)*a*e^(-c^2/b^2 + 2*c*d/b^2 - d^2/b^2 + 2*c*k/b^2 - 2*d*k/b^2 - k^2/b^2)/b + sqrt(pi)*a*e^(-c^2/b^2 + 2*c*d/b^2 - d^2/b^2 - 2*c*k/b^2 + 2*d*k/b^2 - k^2/b^2)/b + sqrt(pi)*a*e^(-c^2/b^2 - 2*c*d/b^2 - d^2/b^2 + 2*c*k/b^2 + 2*d*k/b^2 - k^2/b^2)/b + sqrt(pi)*a*e^(-c^2/b^2 - 2*c*d/b^2 - d^2/b^2 - 2*c*k/b^2 - 2*d*k/b^2 - k^2/b^2)/b
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-03-29 07:11:49 +0200

Seen: 451 times

Last updated: Mar 29 '20