Opened 3 years ago
Closed 3 years ago
#25822 closed defect (invalid)
integral computation with giac crashes giac
Reported by: | tmonteil | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | symbolics | Keywords: | giac, integrate, crash, pexpect |
Cc: | frederichan, parisse, slelievre | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | Fixed upstream, but not in a stable release. | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #26315 | Stopgaps: |
Description (last modified by )
As reported on this Ask Sage question, Giac crashes on the following integral:
sage: print(version()) SageMath version 8.3.rc0, Release Date: 2018-07-08 sage: a, b, c, d, e, x = SR.var('a b c d e x') sage: F = sqrt(d*x^2 + e*x + c)*sqrt((b*x^2 + a)^2)/x^4 sage: FF = integrate(F, x, algorithm='giac') Giac crashed -- automatically restarting. sage:
This is fixed upstream and will be part of the next stable version of Giac.
Another issue when using Giac for integration is the following:
sage: print(version()) SageMath version 8.3.rc0, Release Date: 2018-07-08 sage: a, b, c, d, e, f, g, n, x = SR.var('a b c d e f g n x') sage: G = 1/((g*x + f)^2*(b*log((e*x + d)^n*c) + a)^3) sage: GG = integrate(G, x, algorithm='giac') sage: GG Done sage:
Quoting Frederic Han's comment (with minor edits):
this is a bug of the pexpect Giac interface that takes the string representation of the Giac output. The computation is done in Giac but when the output is large Giac just prints Done, and that is the string that the pxepect interface gets. It is not specific to integrate: it will concern all large Giac output.
Quoting Bernard Parisse's comment:
The maximal size of objects that will be printed should be controllable with the environment variable
GIAC_TAILLEMAX
(default 1000). Size is not the length of the printed string, but the size of thegiac::gen
as defined insymbolic.h
:unsigned taille(const gen & g,unsigned max);
Change History (22)
comment:1 Changed 3 years ago by
- Cc frederichan parisse slelievre added
- Keywords giac integrate added
comment:2 Changed 3 years ago by
comment:3 Changed 3 years ago by
This is expected, if the output is too large.
- Xcas session (open link with Firefox)
comment:4 follow-up: ↓ 7 Changed 3 years ago by
Indeed, this is a bug of the pexpect giac interface that takes the string representation of the giac output. The computation is done in giac but when the output is large giac just prints Done, and that is this string that the pxepect interface get. It is not typical for integrate it will concern all large output.
Bernard, is there a way to disable this in giac/icas or to obtain the string value of the computation?
Note that this problem doesn't appear in giacpy_sage (optionnal package)
sage: var('x g b f n c a d'); sage: F=(1/((g*x + f)^2*(b*log((e*x + d)^n*c) + a)^3)) sage: sage: integrate(F,x, algorithm="giac") Done sage: from giacpy_sage import libgiac // Giac share root-directory:/home/fred-dev/sage/develop/sage.develop/local/share/giac/ // Giac share root-directory:/home/fred-dev/sage/develop/sage.develop/local/share/giac/ Help file /home/fred-dev/sage/develop/sage.develop/local/share/giac/doc/fr/aide_cas not found Added 0 synonyms sage: libgiac(F).integrate(x) (2*a*d^2*g-a*d*f*exp(1)+3*a*d*g*x*exp(1)-a*f*x*exp(1)^2+a*g*x^2*exp(1)^2+2*b*d^2*g*n*ln(d+x*exp(1))+2*b*d^2*g*ln(c)-b*d*f*n*exp(1)*ln(d+x*exp(1))-b*d*f*n*exp(1)-b*d*f*exp(1)*ln(c)+3*b*d*g*n*x*exp(1)*ln(d+x*exp(1))-b*d*g*n*x*exp(1)+3*b*d*g*x*exp(1)*ln(c)-b*f*n*x*exp(1)^2*ln(d+x*exp(1))-b*f*n*x*exp(1)^2-b*f*x*exp(1)^2*ln(c)+b*g*n*x^2*exp(1)^2*ln(d+x*exp(1))-b*g*n*x^2*exp(1)^2+b*g*x^2*exp(1)^2*ln(c))/(2*a^2*b^2*f^3*n^2*exp(1)^2+6*a^2*b^2*f^2*g*n^2*x*exp(1)^2+6*a^2*b^2*f*g^2*n^2*x^2*exp(1)^2+2*a^2*b^2*g^3*n^2*x^3*exp(1)^2+4*a*b^3*f^3*n^3*exp(1)^2*ln(d+x*exp(1))+4*a*b^3*f^3*n^2*exp(1)^2*ln(c)+12*a*b^3*f^2*g*n^3*x*exp(1)^2*ln(d+x*exp(1))+12*a*b^3*f^2*g*n^2*x*exp(1)^2*ln(c)+12*a*b^3*f*g^2*n^3*x^2*exp(1)^2*ln(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*b^2*n^2*exp(1)^2-12*x^2*f^2*g^2*b^3*n^2*ln(c)*exp(1)^2-8*x*a*f^3*g*b^2*n^2*exp(1)^2-8*x*f^3*g*b^3*n^2*ln(c)*exp(1)^2-2*a*f^4*b^2*n^2*exp(1)^2-2*f^4*b^3*n^2*ln(c)*exp(1)^2),x)
comment:5 Changed 3 years ago by
The maximal size of objects that will be printed should be controllable with the environment variable GIAC_TAILLEMAX (default 1000). Size is not the length of the printed string, but the size of the giac::gen as defined in symbolic.h: unsigned taille(const gen & g,unsigned max);
comment:6 Changed 3 years ago by
- Description modified (diff)
- Keywords crash pexpect added
- Report Upstream changed from Not yet reported upstream; Will do shortly. to Fixed upstream, but not in a stable release.
comment:7 in reply to: ↑ 4 Changed 3 years ago by
Replying to frederichan:
Bernard, is there a way to disable this in giac/icas or to obtain the string value of the computation?
It seems we can ask Giac for the string representation using str
.
At least in the web interface, it not return the shorter "Done" output:
- Xcas session (open link in Firefox)
comment:8 Changed 3 years ago by
But sage's pxepect interface is calling icas/giac so it is different than working with the library as does giacpy or the javascript interface. Adding string before evaluation will break manythings such as mulple commands, and after evaluation we will get the Done from icas.
So I think that the easiest thing is to change this in icas.cc, moreover there is already an "insage" booleen flag. I have test successfully the following patch.
Bernard, do you plan to remove the "Done" output in icas.cc when the insage flag is on so that next giac version will solve this without patch?
--- a/src/icas.cc 2017-10-02 10:25:46.000000000 +0200 +++ b/src/icas.cc 2018-07-14 10:50:01.650323754 +0200 @@ -1581,7 +1581,7 @@ int taillemax=1000; if (getenv("GIAC_TAILLEMAX")) taillemax=atoi(getenv("GIAC_TAILLEMAX")); - string s=taille(ge,taillemax)>taillemax?"Done":ge.print(contextptr); + string s=((taille(ge,taillemax)>taillemax)&&(!insage))?"Done":ge.print(contextptr); cout << s; } cout << endl;
comment:9 Changed 3 years ago by
Yes, I made the change in my source (with !insage first).
comment:10 Changed 3 years ago by
Thank you, so in sage the next giac update should solve these problems automatically.
comment:11 Changed 3 years ago by
fyi, this is similar giac crash. I tried to report it to giac, but could not get an account on giac tracking. I submitted request to join and never heard back. So posting it here. May be someone who knows how to report them to giac bugs database would be able to do this since I can't.
sage: version() 'SageMath version 8.3.rc0, Release Date: 2018-07-08 sage: var('d x c b a f e') (d, x, c, b, a, f, e) sage: integrate(sin((d*x + c)^(2/3)*b + a)/(f*x + e),x, algorithm="giac") Giac crashed -- automatically restarting. sage0*x sage: integrate(sin((d*x + c)^(2/3)*b + a)/(f*x + e)^2,x,algorithm="giac") Giac crashed -- automatically restarting. sage4*x sage: integrate(sin(a + b/(d*x + c)^(2/3))/(f*x + e),x, algorithm="giac") Giac crashed -- automatically restarting. sage8*x sage: integrate(sin(a + b/(d*x + c)^(2/3))/(f*x + e)^2,x, algorithm="giac") Giac crashed -- automatically restarting. sage12*x
comment:12 Changed 3 years ago by
Crash fixed in source. If you want to register in the Xcas forum, please choose a login or an email that can not be confused with a spammer, or send me a mail asking explicitly for activation.
comment:13 follow-up: ↓ 15 Changed 3 years ago by
crash fixed by #26315. The 2nd integral is however not computed by giac 1.5.0-37, I get
sage: a, b, c, d, e, f, g, n, x = SR.var('a b c d e f g n x') sage: G = 1/((g*x + f)^2*(b*log((e*x + d)^n*c) + a)^3) sage: GG = integrate(G, x, algorithm='giac') sage: GG integrate(1/((g*x + f)^2*(b*log((e*x + d)^n*c) + a)^3), x) sage: GG = integrate(G, x) sage: GG 1/2*((a*e^2*g - (e^2*g*n - e^2*g*log(c))*b)*x^2 - (d*e*f - 2*d^2*g)*a - (d*e*f*n + (d*e*f - 2*d^2*g)*log(c))*b - ((e^2*f - 3*d*e*g)*a + (e^2*f*n + d*e*g*n + (e^2*f - 3*d*e*g)*log(c))*b)*x + (b*e^2*g*x^2 - (e^2*f - 3*d*e*g)*b*x - (d*e*f - 2*d^2*g)*b)*log((e*x + d)^n))/(b^4*e^2*f^3*n^2*log(c)^2 + 2*a*b^3*e^2*f^3*n^2*log(c) + a^2*b^2*e^2*f^3*n^2 + (b^4*e^2*g^3*n^2*log(c)^2 + 2*a*b^3*e^2*g^3*n^2*log(c) + a^2*b^2*e^2*g^3*n^2)*x^3 + 3*(b^4*e^2*f*g^2*n^2*log(c)^2 + 2*a*b^3*e^2*f*g^2*n^2*log(c) + a^2*b^2*e^2*f*g^2*n^2)*x^2 + (b^4*e^2*g^3*n^2*x^3 + 3*b^4*e^2*f*g^2*n^2*x^2 + 3*b^4*e^2*f^2*g*n^2*x + b^4*e^2*f^3*n^2)*log((e*x + d)^n)^2 + 3*(b^4*e^2*f^2*g*n^2*log(c)^2 + 2*a*b^3*e^2*f^2*g*n^2*log(c) + a^2*b^2*e^2*f^2*g*n^2)*x + 2*(b^4*e^2*f^3*n^2*log(c) + a*b^3*e^2*f^3*n^2 + (b^4*e^2*g^3*n^2*log(c) + a*b^3*e^2*g^3*n^2)*x^3 + 3*(b^4*e^2*f*g^2*n^2*log(c) + a*b^3*e^2*f*g^2*n^2)*x^2 + 3*(b^4*e^2*f^2*g*n^2*log(c) + a*b^3*e^2*f^2*g*n^2)*x)*log((e*x + d)^n)) + integrate(1/2*(e^2*g^2*x^2 + e^2*f^2 - 6*d*e*f*g + 6*d^2*g^2 - 2*(2*e^2*f*g - 3*d*e*g^2)*x)/(b^3*e^2*f^4*n^2*log(c) + a*b^2*e^2*f^4*n^2 + (b^3*e^2*g^4*n^2*log(c) + a*b^2*e^2*g^4*n^2)*x^4 + 4*(b^3*e^2*f*g^3*n^2*log(c) + a*b^2*e^2*f*g^3*n^2)*x^3 + 6*(b^3*e^2*f^2*g^2*n^2*log(c) + a*b^2*e^2*f^2*g^2*n^2)*x^2 + 4*(b^3*e^2*f^3*g*n^2*log(c) + a*b^2*e^2*f^3*g*n^2)*x + (b^3*e^2*g^4*n^2*x^4 + 4*b^3*e^2*f*g^3*n^2*x^3 + 6*b^3*e^2*f^2*g^2*n^2*x^2 + 4*b^3*e^2*f^3*g*n^2*x + b^3*e^2*f^4*n^2)*log((e*x + d)^n)), x)
It appears however that the latter integration (by maxima?) is not correct. Can this integral be computed in elementary functions?
comment:14 Changed 3 years ago by
- Milestone changed from sage-8.3 to sage-8.7
- Status changed from new to needs_info
comment:15 in reply to: ↑ 13 Changed 3 years ago by
Replying to dimpase:
crash fixed by #26315. The 2nd integral is however not computed by giac 1.5.0-37, I get
sage: a, b, c, d, e, f, g, n, x = SR.var('a b c d e f g n x') sage: G = 1/((g*x + f)^2*(b*log((e*x + d)^n*c) + a)^3)
Can this integral be computed in elementary functions?
Very unlikely:
sage: a, b, c, d, e, f, g, n, x = SR.var('a b c d e f g n x') sage: G = 1/((g*x + f)^2*(b*log((e*x + d)^n*c) + a)^3) sage: G1 = G.subs(n=1, c=1, b=1, f=1, g=1, a=0, e=1); G1 1/((x + 1)^2*log(d + x)^3) sage: integrate(G1, x, algorithm="fricas") integral(1/((x^2 + 2*x + 1)*log(d + x)^3), x)
(I also tried a well known online tool.)
comment:16 follow-up: ↓ 17 Changed 3 years ago by
- Milestone changed from sage-8.7 to sage-duplicate/invalid/wontfix
- Status changed from needs_info to positive_review
Yes, as integrate(G1, x)
gives nonsense, this is yet another maxima bug. No problems with giac
here, anyway, closing.
comment:17 in reply to: ↑ 16 ; follow-up: ↓ 18 Changed 3 years ago by
Replying to dimpase:
Yes, as
integrate(G1, x)
gives nonsense, this is yet another maxima bug. No problems withgiac
here, anyway, closing.
No, the result is correct, it is just not very helpful:
sage: (diff(integrate(G1, x), x) - G1).simplify_full() 0
comment:18 in reply to: ↑ 17 Changed 3 years ago by
Replying to mantepse:
Replying to dimpase:
Yes, as
integrate(G1, x)
gives nonsense, this is yet another maxima bug. No problems withgiac
here, anyway, closing.No, the result is correct, it is just not very helpful:
sage: (diff(integrate(G1, x), x) - G1).simplify_full() 0
the result of the computation without fixing parameters seems to be incorrect, that's what I was trying to say.
comment:19 Changed 3 years ago by
- Milestone changed from sage-duplicate/invalid/wontfix to sage-pending
- Status changed from positive_review to needs_work
This is not fixed in 8.6, i still get the errors. This ticket should depend on #26315 and requires a dedicated doctest.
comment:20 Changed 3 years ago by
Please add all the doctests you see fit on the branch of #26315 - I just don't see why we should test giac more than it tests itself...
comment:21 Changed 3 years ago by
- Dependencies set to #26315
- Milestone changed from sage-pending to sage-duplicate/invalid/wontfix
- Status changed from needs_work to positive_review
no work should be done on this ticket, hence positive review.
comment:22 Changed 3 years ago by
- Resolution set to invalid
- Status changed from positive_review to closed
Presuming these are all correctly reviewed as either duplicate, invalid, or wontfix.
Here is another bug in GIAC/XCAS, may be it should be added to above? since it is also in integrate? I did not know if I should open a new one or not, since it is same system. Here it is. This is a bug in giac used by sagemath. It returns "done" as result of integrate.