Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqrt(-r_0^2 + r_1^2 + 2*r_0*x - x^2): Maxima gives an antiderivative but *crashes* on definite integral #27816

Open
EmmanuelCharpentier mannequin opened this issue May 12, 2019 · 3 comments

Comments

@EmmanuelCharpentier
Copy link
Mannequin

EmmanuelCharpentier mannequin commented May 12, 2019

Inspired by this ask.sagemath.org question:

var("x, y, t, r_0, r_1, X", domain="real")
rr=var("rr")
assume(r_0>0,X<r_0,r_1>0,r_1<2*r_0,rr>0)
with assuming(y>0): foo=solve(x^2 + y^2 == r_0^2, y)[0].rhs()
Y_0(x)=foo
with assuming(y>0): foo=solve((r_0-x)^2 + y^2 == r_1^2, y)[0].rhs()
Y_1(x)=foo
X=solve(Y_1(x)^2==Y_0(x)^2,x)[0].rhs()
g(x)=integrate(Y_1(x),x).expand()

So far, so good :

sage: (g(X)-g(r_0-r_1)).expand()
1/4*pi*r_1^2 - 1/2*r_1^2*arcsin(1/2*r_1/r_0) - 1/8*sqrt(4*r_1^2 - r_1^4/r_0^2)*r_1^2/r_0

But integrate(Y_1(x),x,r_0-r_1,X).expand() crashes Maxima (and Sage) :

sage: integrate(Y_1(x),x,r_0-r_1,X)

;;;
;;; Detected access to protected memory, also kwown as 'bus or segmentation fault'.
;;; Jumping to the outermost toplevel prompt
;;;

repeated /ad nauseam/...

This can be reproduced in Maxima. This works as expected:

assume(r_0>0,X<r_0,r_1>0,r_1<2*r_0,rr>0);
assume(y>0);
define(Y_0(x),rhs(solve(x^2+y^2=r_0^2,y)[2]));
define(Y_1(x),rhs(solve((r_0-x)^2+y^2=r_1^2,y)[2]));
X:rhs(solve(Y_0(x)^2=Y_1(x)^2,x)[1]);
Y:Y_0(X);
define(g(x),expand(integrate(Y_1(x),x)));
g(X)-g(r_0-r_1);

But asking for integrate(Y_1(x),x,r_0-r_1,X); crashes Maxima with the same error messages...

This seems different from bugs already reported on definite integration.

FWIW, both giac and fricas give acceptable answers (different in their integration process : one uses arcsin, the other arctan, with similar geometric interpretation...).

Upstream: Not yet reported upstream; Will do shortly.

Component: symbolics

Keywords: definite integral

Issue created by migration from https://trac.sagemath.org/ticket/27816

@EmmanuelCharpentier EmmanuelCharpentier mannequin added this to the sage-8.8 milestone May 12, 2019
@EmmanuelCharpentier
Copy link
Mannequin Author

EmmanuelCharpentier mannequin commented Jun 6, 2019

comment:1

This is still true in 8.8.beta7, which has maxima 5.42.2...

@embray
Copy link
Contributor

embray commented Jun 14, 2019

comment:2

As the Sage-8.8 release milestone is pending, we should delete the sage-8.8 milestone for tickets that are not actively being worked on or that still require significant work to move forward. If you feel that this ticket should be included in the next Sage release at the soonest please set its milestone to the next release milestone (sage-8.9).

@embray embray removed this from the sage-8.8 milestone Jun 14, 2019
@oldk1331
Copy link

With maxima-5.47.0, it works in sage-10.2 by default (domain:complex;):

sage: integrate(Y_1(x),x,r_0-r_1,X).expand()
-1/2*r_1^2*arctan(sqrt(4*r_0^2 - r_1^2)/r_1) - 1/8*I*sqrt(-4*r_0^2 + r_1^2)*r_1^3/r_0^2

But in maxima, the default domain : real; gives:

(%i10) domain : complex;
(%o10)                              complex
(%i11) integrate(Y_1(x),x,r_0-r_1,X);
                                         2
       (%i (2 log(2) - log(4)) + %pi) r_1
(%o11) -----------------------------------
                        4
                                2      2            2
       2    2         sqrt(4 r_0  - r_1 ) sqrt(4 r_1 )
 - (r_0  r_1  (4 atan(--------------------------------)
                                        2
                                   2 r_1
                                              3         2        2         2
 + %i (4 log(4) - 2 log(16)) + 2 %pi) + %i r_1  sqrt(r_1  - 4 r_0 ))/(8 r_0 )
(%i12) domain : real;
(%o12)                               real
(%i13) integrate(Y_1(x),x,r_0-r_1,X);

Maxima encountered a Lisp error:

 binding-stack overflow at size 10240. Stack can probably be resized.
Proceed with caution.

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants