Ask Your Question
0

C-STACK overflow during integration

asked 5 years ago

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

Preview: (hide)

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 ( 5 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 5 years ago

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
Preview: (hide)
link

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: 5 years ago

Seen: 642 times

Last updated: Mar 29 '20