# C-STACK overflow during integration

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?

edit retag close merge delete

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.

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

Sort by ยป oldest newest most voted

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

more