Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
2

Stack overflow during symbolic manipulations

asked 4 years ago

Florentin Jaffredo gravatar image

updated 2 years ago

tmonteil gravatar image

I'm trying to evaluate this cursed integral (finite for 0<a<1):

10xlog(ax+(1x)2)dx

using Sagemath 9.0 and 9.1:

sage: a = var('a')
sage: assume(a>0)
sage: assume(a<1)
sage: f = integrate(x*log(1/(a*x+(1-x)^2)), x, 0, 1)

leads to

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

Sympy gives a result even without the assumptions (which is odd by itself):

sage: f = integrate(x*log(1/(a*x+(1-x)*(1-x))), x, 0, 1, algorithm='sympy')

14(a2+(a4)a(a2)4a+2)log(a2+(a4)a(a2)4a+42(a2)+1)14(a2+(a4)a(a2)4a+2)log(a2+(a4)a(a2)4a+42(a2))+14(a2(a4)a(a2)4a+2)log(a2(a4)a(a2)4a+42(a2)+1)14(a2(a4)a(a2)4a+2)log(a2(a4)a(a2)4a+42(a2))12a+12log(1a)+32

But then problems continue:

sage: f.simplify_full()

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

But:

sage: f.expand().simplify_full()

12(2π(πarctan(a+4a)+arctan(aa+4a2))a2arctan(a+4a)+2arctan(aa+4a2))aa+4+14(a24a)log(a)12a+32 If I want to find the limit when a0:

sage: f.limit(a=0)

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

and once again

 sage: f.limit(a=0, algorithm="sympy")

iπ+32

Which is only true for a<0.

I previously found this strange bug a while ago (fixed upstream, still present in Sagemath 9.1), this makes me think the assumption assume(a>0) is the root of it all, unfortunately it cannot be skipped to evaluate the integral properly.

Do you know when the updated version of Maxima will be included with Sagemath?
Do you think all these issues are linked to this old ticket or should it be investigated independently?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 4 years ago

tmonteil gravatar image

Thanks for reporting, this is clrealy a bug, it is now trac ticket 30353. The latest Maxima release fixes it, so, when trac ticket 30063 will be merged, you will get:

sage: a = var('a')                                                                                                                                                                                           
sage: assume(a>0)                                                                                                                                                                                            
sage: assume(a<1)                                                                                                                                                                                            
sage: f = integrate(x*log(1/(a*x+(1-x)^2)), x, 0, 1)                                                                                                                                                         
sage: f                                                                                                                                                                                                      
1/4*a^2*log(a) + 1/2*sqrt(-a^2 + 4*a)*a*arctan(sqrt(-a^2 + 4*a)*(a - 2)/(a^2 - 4*a)) - 1/2*sqrt(-a^2 + 4*a)*a*arctan(sqrt(-a^2 + 4*a)/(a - 4)) - a*log(a) - sqrt(-a^2 + 4*a)*arctan(sqrt(-a^2 + 4*a)*(a - 2)/(a^2 - 4*a)) + sqrt(-a^2 + 4*a)*arctan(sqrt(-a^2 + 4*a)/(a - 4)) - 1/2*a + 3/2
sage: f = integrate(x*log(1/(a*x+(1-x)*(1-x))), x, 0, 1, algorithm='sympy')                                                                                                                                  
sage: f.simplify_full()                                                                                                                                                                                      
1/4*(a^2 - 4*a + 2)*log(1/2*a + 1/2*sqrt(a^2 - 4*a)) - 1/4*(a^2 - 4*a + 2)*log(1/2*a + 1/2*sqrt(a^2 - 4*a) - 1) + 1/4*(a^2 - 4*a + 2)*log(1/2*a - 1/2*sqrt(a^2 - 4*a)) - 1/4*(a^2 - 4*a + 2)*log(1/2*a - 1/2*sqrt(a^2 - 4*a) - 1) + 1/4*sqrt(a^2 - 4*a)*((a - 2)*log(1/2*a + 1/2*sqrt(a^2 - 4*a)) - (a - 2)*log(1/2*a + 1/2*sqrt(a^2 - 4*a) - 1) - (a - 2)*log(1/2*a - 1/2*sqrt(a^2 - 4*a)) + (a - 2)*log(1/2*a - 1/2*sqrt(a^2 - 4*a) - 1)) - 1/2*a - 1/2*log(a) + 3/2
sage: f.limit(a=0)                                                                                                                                                                                           
-I*pi + 3/2
Preview: (hide)
link

Comments

Ticket #30063, which upgrades to Maxima 5.44.0 and thus fixes this behaviour, was merged in Sage 9.2.beta10. Ticket #30353, which adds a test to Sage so that this problem never comes back, was merged in Sage 9.2.beta11. Any later version of Sage, in particular Sage 9.2 or any later version, is free from this bug. This answer by @tmonteil should be the accepted answer rather than mine.

slelievre gravatar imageslelievre ( 4 years ago )

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

Seen: 678 times

Last updated: Aug 14 '20