Opened 7 months ago

Last modified 5 weeks ago

#31222 new defect

Many integrals fail now using sagemath 9.2 using giac algorithm

Reported by: gh-nasser1 Owned by:
Priority: major Milestone: sage-9.4
Component: symbolics Keywords: integrate, giac, interface
Cc: chapoton, charpent, frederichan, gh-mwageringel, gh-nasser1, slelievre Merged in:
Authors: Reviewers:
Report Upstream: Reported upstream. Developers acknowledge bug. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by dimpase)

Edit: the root cause of the problem described here is very high sensitivity of giac to the form of the input to its integrator: e.g. different order of terms in a product to be integrated may lead to huge slowdowns/hands,cf Example 8, and Sage does rewriting of terms before passing them to an external integrator. Namely, if F is the original input then giac gets F._giac_init_(), which is often not exacly F, although equavalent to F. In this sense, passing a string to giac might be more robust.


Hello. I am working on a new build and new reports for the independent CAS integration tests https://www.12000.org/my_notes/CAS_integration_tests/index.htm.

Now using sagemath 9.2 on Linux to test thousands of integrals using fricas, maxima and giac among other CAS systems.

I found that hundreds of integrals now fail when using giac version 1.6, which all work on giac itself, and also which all worked using sagemath 8.9 using giac 1.5 which I did last year.

It fails either by now hanging or not evaluating. The ones that hang in sagemath, complete immediately in giac.

Since there so many integrals that now fail, I will only show few examples below. Hopefully the cause of the failure is the same for all. If not, I can provide more examples.

Example 1, do not evaluate any more

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.2, Release Date: 2020-10-24                     │
│ Using Python 3.8.6. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
sage: x,a = var('x a')
sage: integrate(sin(2*x)/(a^2-4*sin(x)^2)^(1/3),x, algorithm="giac")
integrate(sin(2*x)/(a^2 - 4*sin(x)^2)^(1/3), x)
sage: 

Using giac directly

>giac
// Using locale /usr/share/locale/
// en_US.utf8
// /usr/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 2
Help file /usr/share/giac/doc/en/aide_cas not found
Added 26 synonyms
Welcome to giac readline interface
(c) 2001,2020 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate(sin(2*x)/(a^2-4*sin(x)^2)^(1/3),x)
-3/4*((a^2-2*(-2*cos(2*x)/2+1))^(1/3))^2/2
// Time 0.01
1>> 

Example 2. Hangs now in sagemath

sage: x,a,b = var('x a b')
sage: integrate(x^(5/2)/(b*x+a)^(5/2),x, algorithm="giac")


While in giac, completes right away

>> integrate(x^(5/2)/(b*x+a)^(5/2),x)
2*(2*((9*b^4*a*1/36/b^5/a*sqrt(x)*sqrt(x)+60*b^3*a^2*1/36/b^5/a)*sqrt(x)*sqrt(x)+45*b^2*a^3*1/36/b^5/a)*sqrt(x)*sqrt(a+b*x)/(a+b*x)^2+10*a/4/b^3/sqrt(b)*ln(abs(sqrt(a+b*x)-sqrt(b)*sqrt(x))))
// Time 0.02


Example 3, hangs

integrate(x^(3/2)/(b*x+a)^(5/2),x, algorithm="giac")

Using giac directly, it completes right away

14>> integrate(x^(3/2)/(b*x+a)^(5/2),x)
2*(2*(-12*b^2*a*1/18/b^3/a*sqrt(x)*sqrt(x)-9*b*a^2*1/18/b^3/a)*sqrt(x)*sqrt(a+b*x)/(a+b*x)^2-1/b^2/sqrt(b)*ln(abs(sqrt(a+b*x)-sqrt(b)*sqrt(x))))
// Time 0.03

Most of the ones that fail now looks like due to hang. But also some fail because the integral do not evaluate in sagemath, but it does using giac directly.

Version information

which giac
/bin/giac
>
>
>giac --version
// Using locale /usr/share/locale/
// en_US.utf8
// /usr/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 2
// (c) 2001, 2018 B. Parisse & others
1.6.0
>
>


>which sage
/bin/sage
>sage --version
SageMath version 9.2, Release Date: 2020-10-24
>

Linux Manjaro running inside Oracle Virtual Box

>uname -r
5.4.80-2-MANJARO
>uname -a
Linux me-virtualbox 5.4.80-2-MANJARO #1 SMP PREEMPT Sat Nov 28 09:58:18 UTC 2020 x86_64 GNU/Linux
>

>lsb_release -a
LSB Version:	n/a
Distributor ID:	ManjaroLinux
Description:	Manjaro Linux
Release:	20.2
Codename:	Nibia



Because of this, I stopped the tests. And will wait for next version of sagemath, hopefully it have a fix for this, as giac result are now looking not good due to this.

Please feel free to add any fields for the ticket if needed. I filled the ones I know about.

Thank you, --Nasser

Adding more examples

EXAMPLE 4 (hangs in sagemath)

>giac
// Using locale /usr/share/locale/
// en_US.utf8
// /usr/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 2
Help file /usr/share/giac/doc/en/aide_cas not found
Added 26 synonyms
Welcome to giac readline interface
(c) 2001,2020 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate(x*(b*x^2+a)*(B*x^2+A),x)
1/2*(1/3*x^6*b*B+1/2*x^4*b*A+1/2*x^4*a*B+x^2*a*A)
// Time 0


>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.2, Release Date: 2020-10-24                     │
│ Using Python 3.8.6. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
sage: x,a,b,B,A = var('x a b B A')
sage: integrate(x*(b*x^2+a)*(B*x^2+A),x, algorithm="giac")


EXAMPLE 5 (hangs in sagemath)

GIAC:

3>> integrate(x^m*(b*x^2+a)^3*(B*x^2+A),x)
(A*a^3*m^4*x*exp(m*ln(x))+24*A*a^3*m^3*x*exp(m*ln(x))+206*A*a^3*m^2*x*exp(m*ln(x))+744*A*a^3*m*x*exp(m*ln(x))+945*A*a^3*x*exp(m*ln(x))+3*A*a^2*b*m^4*x^3*exp(m*ln(x))+66*A*a^2*b*m^3*x^3*exp(m*ln(x))+492*A*a^2*b*m^2*x^3*exp(m*ln(x))+1374*A*a^2*b*m*x^3*exp(m*ln(x))+945*A*a^2*b*x^3*exp(m*ln(x))+3*A*a*b^2*m^4*x^5*exp(m*ln(x))+60*A*a*b^2*m^3*x^5*exp(m*ln(x))+390*A*a*b^2*m^2*x^5*exp(m*ln(x))+900*A*a*b^2*m*x^5*exp(m*ln(x))+567*A*a*b^2*x^5*exp(m*ln(x))+A*b^3*m^4*x^7*exp(m*ln(x))+18*A*b^3*m^3*x^7*exp(m*ln(x))+104*A*b^3*m^2*x^7*exp(m*ln(x))+222*A*b^3*m*x^7*exp(m*ln(x))+135*A*b^3*x^7*exp(m*ln(x))+B*a^3*m^4*x^3*exp(m*ln(x))+22*B*a^3*m^3*x^3*exp(m*ln(x))+164*B*a^3*m^2*x^3*exp(m*ln(x))+458*B*a^3*m*x^3*exp(m*ln(x))+315*B*a^3*x^3*exp(m*ln(x))+3*B*a^2*b*m^4*x^5*exp(m*ln(x))+60*B*a^2*b*m^3*x^5*exp(m*ln(x))+390*B*a^2*b*m^2*x^5*exp(m*ln(x))+900*B*a^2*b*m*x^5*exp(m*ln(x))+567*B*a^2*b*x^5*exp(m*ln(x))+3*B*a*b^2*m^4*x^7*exp(m*ln(x))+54*B*a*b^2*m^3*x^7*exp(m*ln(x))+312*B*a*b^2*m^2*x^7*exp(m*ln(x))+666*B*a*b^2*m*x^7*exp(m*ln(x))+405*B*a*b^2*x^7*exp(m*ln(x))+B*b^3*m^4*x^9*exp(m*ln(x))+16*B*b^3*m^3*x^9*exp(m*ln(x))+86*B*b^3*m^2*x^9*exp(m*ln(x))+176*B*b^3*m*x^9*exp(m*ln(x))+105*B*b^3*x^9*exp(m*ln(x)))/(m^5+25*m^4+230*m^3+950*m^2+1689*m+945)
// Time 0.01
4>> 


SAGEMATH:

sage: x,a,b,B,A,m = var('x a b B A m')
sage: integrate(x^m*(b*x^2+a)^3*(B*x^2+A),x, algorithm="giac")


EXAMPLE 6 (hangs in sagemath)

GIAC:

4>> integrate(x^4*log(d*(c*x^2+b*x+a)^n),x)
(-2/25*n+1/5*ln(d))*x^5+b*n/(20*c)*x^4+(2*a*c*n-b^2*n)/(15*c^2)*x^3+(-3*a*b*c*n+b^3*n)/(10*c^3)*x^2+(-2*a^2*c^2*n+4*a*b^2*c*n-b^4*n)/(5*c^4)*x+1/5*n*x^5*ln(a+b*x+c*x^2)+integrate((x*n*b^5-5*x*n*b^3*c*a+5*x*n*b*c^2*a^2+n*b^4*a-4*n*b^2*c*a^2+2*n*c^2*a^3)/(5*x^2*c^5+5*x*b*c^4+5*c^4*a),x)
// Time 0.01
5>> 

SAGEMATH:

sage: x,a,b,B,A,m,n,d,c = var('x a b B A m n d c')
sage: integrate(x^4*log(d*(c*x^2+b*x+a)^n),x, algorithm="giac")


EXAMPLE 7 (hangs in sagemath)

5>> integrate(x^3*log(d*(c*x^2+b*x+a)^n),x)
(-1/8*n+1/4*ln(d))*x^4+b*n/(12*c)*x^3+(2*a*c*n-b^2*n)/(8*c^2)*x^2+(-3*a*b*c*n+b^3*n)/(4*c^3)*x+1/4*n*x^4*ln(a+b*x+c*x^2)+integrate((-x*n*b^4+4*x*n*b^2*c*a-2*x*n*c^2*a^2-n*b^3*a+3*n*b*c*a^2)/(4*x^2*c^4+4*x*b*c^3+4*c^3*a),x)
// Time 0.02

sage: x,a,b,B,A,m,n,d,c = var('x a b B A m n d c')
sage: integrate(x^3*log(d*(c*x^2+b*x+a)^n),x, algorithm="giac")


EXAMPLE 8 (hangs in sagemath)

0>> integrate(exp(-b*x-a)*(b*x+a)^4*(d*x+c)^3,x)
Done
// Time 0.01

sage: x,a,b,B,A,m,n,d,c = var('x a b B A m n d c')
sage: integrate(exp(-b*x-a)*(b*x+a)^4*(d*x+c)^3,x, algorithm="giac")


EXAMPLE 9 (hangs in sagemath)

1>> integrate(exp(-b*x-a)*(b*x+a)^4*(d*x+c),x)
(-x^5*d*b^9-4*x^4*a*d*b^8-x^4*c*b^9-5*x^4*d*b^8-6*x^3*a^2*d*b^7-4*x^3*a*c*b^8-16*x^3*a*d*b^7-4*x^3*c*b^8-20*x^3*d*b^7-4*x^2*a^3*d*b^6-6*x^2*a^2*c*b^7-18*x^2*a^2*d*b^6-12*x^2*a*c*b^7-48*x^2*a*d*b^6-12*x^2*c*b^7-60*x^2*d*b^6-x*a^4*d*b^5-4*x*a^3*c*b^6-8*x*a^3*d*b^5-12*x*a^2*c*b^6-36*x*a^2*d*b^5-24*x*a*c*b^6-96*x*a*d*b^5-24*x*c*b^6-120*x*d*b^5-a^4*c*b^5-a^4*d*b^4-4*a^3*c*b^5-8*a^3*d*b^4-12*a^2*c*b^5-36*a^2*d*b^4-24*a*c*b^5-96*a*d*b^4-24*c*b^5-120*d*b^4)/b^6*exp(-(a+b*x))
// Time 0

sage: x,a,b,B,A,m,n,d,c = var('x a b B A m n d c')
sage: integrate(exp(-b*x-a)*(b*x+a)^4*(d*x+c),x, algorithm="giac")


Attachments (1)

SAGE.zip (5.3 MB) - added by gh-nasser1 7 months ago.
Contains RUBI integration problems in sagemath synyax

Change History (36)

comment:1 Changed 7 months ago by gh-nasser1

  • Description modified (diff)

comment:2 Changed 7 months ago by slelievre

  • Cc chapoton frederichan gh-mwageringel gh-nasser1 slelievre added
  • Keywords changed from integrate,giac,interface to integrate, giac, interface
  • Type changed from PLEASE CHANGE to defect

comment:3 Changed 7 months ago by dimpase

everything works in the current beta. I guess your Sage install is broken.

│ SageMath version 9.3.beta5, Release Date: 2020-12-27               │
│ Using Python 3.7.7. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: sage: x,a = var('x a')                                                                                                                                                                                                                                            
sage: sage: integrate(sin(2*x)/(a^2-4*sin(x)^2)^(1/3),x, algorithm="giac")                                                                                                                                                                                              
-3/8*(a^2 - 16*tan(1/2*x)^2/(tan(1/2*x)^2 + 1)^2)^(2/3)
sage:             

comment:4 Changed 7 months ago by dimpase

It looks like this is about Sage 9.2 installed, as a system package, on a particular Linux, what is Linux in question?

comment:5 Changed 7 months ago by gh-nasser1

version information for linux

>uname -a
Linux me-virtualbox 5.4.80-2-MANJARO #1 SMP PREEMPT Sat Nov 28 09:58:18 UTC 2020 x86_64 GNU/Linux
>uname -r
5.4.80-2-MANJARO

I installed 9.2 via Linux package manager and all was installed correctly. sagemath works fine.

comment:6 Changed 7 months ago by dimpase

your report indicates that Sage's interface with giac is broken in your installation.

comment:7 follow-up: Changed 7 months ago by tmonteil

@dimpase could you please try the other examples ? On my computer (Sage 9.3.beta5, compiled by myself, Debian buster), the first example works, but not the other ones.

comment:8 follow-up: Changed 7 months ago by tmonteil

@gh-nasser1 if you have interesting examples, you should add them as doctests within Sage so that we could see regressions immediately.

comment:9 Changed 7 months ago by chapoton

The second example seems to hand in giac 1.5 itself. Maybe giac 1.6 makes a difference.

comment:10 Changed 7 months ago by gh-DaveWitteMorris

FWIW: My experience matches that of tmonteil in comment:7. This is with 9.3.beta5 on MacOS 10.15.7.

(The result for the 1st integral is the same as reported by dimpasse in comment:3. It looks different from what is reported in the ticket description, but I believe the two expressions are equal, so that is not a problem.)

comment:11 in reply to: ↑ 8 ; follow-ups: Changed 7 months ago by gh-DaveWitteMorris

@gh-nasser1: Thanks for reporting this problem. It seems to be serious, but I hope it will have an easy solution.

It seems that you have translated the rubi tests to sagemath format. If so, would you be willing to share the zip file, perhaps as an attachment to this ticket?

comment:12 Changed 7 months ago by gh-nasser1

  • Description modified (diff)

Changed 7 months ago by gh-nasser1

Contains RUBI integration problems in sagemath synyax

comment:13 in reply to: ↑ 11 ; follow-up: Changed 7 months ago by gh-nasser1

Replying to gh-DaveWitteMorris:

@gh-nasser1: Thanks for reporting this problem. It seems to be serious, but I hope it will have an easy solution.

It seems that you have translated the rubi tests to sagemath format. If so, would you be willing to share the zip file, perhaps as an attachment to this ticket?

I seem to have lost what I wrote here. WIll try again.

I attached zip file to the ticket. Each file in the zip file, say "Hebisch_Problems.sage" has first line as the var command, followed by lis which is a list that contains all the integrals for that specific test.

To run one file you could do

fileName = "Hebisch_Problems.sage"
load(fileName) #read the problems into variable lis. This also contains the var('') statement.
for problem in lst: #problem[0] is the integrand, problem[1] is the integration variable.
    integrate(SR(problem[0]),problem[1],algorithm="giac")

Each row in the list has as first field the integrand (as a string) and the second field is the integration variable.

Of you could simply copy the integral from the files and past it to sagemath.

Here is an example of one small complete file. There are about 200 files, some contains thousands of integrals. But they all have this format:

var('x ')
lst=[["(x^6-x^5+x^4-x^3+1)*exp(x)",x,25,"871*exp(x)-870*exp(x)*x+435*exp(x)*x^2-145*exp(x)*x^3+36*exp(x)*x^4-7*exp(x)*x^5+exp(x)*x^6"],
["(-x^2+2)*exp(x/(x^2+2))/(x^3+2*x)",x,-5,"Ei(x/(x^2+2))"],
["(2*x^4-x^3+3*x^2+2*x+2)*exp(x/(x^2+2))/(x^3+2*x)",x,-5,"exp(x/(x^2+2))*(x^2+2)+Ei(x/(x^2+2))"],
["(1+exp(x))*exp(x+exp(x))/(x+exp(x))",x,2,"Ei(x+exp(x))"],
["(x^3-x^2-3*x+1)*exp(1/(x^2-1))/(x^3-x^2-x+1)",x,-6,"exp(1/(x^2-1))*(1+x)"],
["exp(1+1/log(x))*(-1+log(x)^2)/log(x)^2",x,1,"exp(1+1/log(x))*x"],
["exp(x+1/log(x))*(-1+(1+x)*log(x)^2)/log(x)^2",x,-2,"exp(x+1/log(x))*x"]]

--Nasser

Last edited 7 months ago by gh-nasser1 (previous) (diff)

comment:14 in reply to: ↑ 13 Changed 7 months ago by gh-DaveWitteMorris

Replying to gh-nasser1:

I attached zip file to the ticket...

Thanks! Your instructions were very clear, so I had no problem running some tests (until I ran into one that hangs). As suggested by tmonteil in comment:8, I think a bunch of these should be added to the testing framework after this bug is cleared up.

comment:15 in reply to: ↑ 7 Changed 7 months ago by dimpase

Replying to tmonteil:

@dimpase could you please try the other examples ? On my computer (Sage 9.3.beta5, compiled by myself, Debian buster), the first example works, but not the other ones.

oops, indeed, while the 1st example works for me, the 2nd one hangs. Sorry for noise.

comment:16 Changed 7 months ago by dimpase

Something silly is happening where the expression to pass to giac is formed. I've added

  • src/sage/interfaces/giac.py

    a b class GiacElement(ExpectElement): 
    11541154            sage: x,y=giac('x'),giac('y');integrate(cos(x+y),'x=0..pi').simplify()
    11551155            -2*sin(y)
    11561156        """
     1157        print(self.name())
     1158        print(self)
     1159        print(var)
    11571160        if min is None:
    11581161            return giac('int(%s,%s)' % (self.name(), var))
    11591162        else:

and as you see, the expression is malformed, e.g. there is no terminating ) so giac just waits for the end of the expression, which never comes, thus the hang.

sage: sage: x,a,b = var('x a b') 
....: sage: integrate((x/(b*x+a))^(5/2),x, algorithm="giac")                                                                                                                                                                                                                      
sage4
sqrt((b*x+a)^-1*x)*((b*x+a)^-1*x)^2
x
^CInterrupting Giac...

comment:17 Changed 7 months ago by dimpase

and here is the malformed giac input for Example 2 as given in the ticket description

sage: sage: x,a,b = var('x a b') 
....: sage: integrate(x^(5/2)/(b*x+a)^(5/2),x, algorithm="giac")                                                                                                                                                                                                                  
sage0
(sqrt(b*x+a))^-1*(b*x+a)^-2*sqrt(x)*x^2
x
^CInterrupting Giac...

somebody has damaged handling of non-integer exponents (for giac only?) since Sage 8.9, it seems.

comment:18 Changed 7 months ago by dimpase

On the other hand, integrate(x^(5/2)/(b*x+a)^(5/2),x, algorithm="fricas") works, which gives hope that the bug is specific to giac interface.

comment:19 follow-up: Changed 7 months ago by chapoton

sorry, but where do you see a missing parenthesis ? The following works fine:

sage: x,a,b = var('x a b')                                                      
sage: F=(x/(b*x+a))^(5/2)                                                       
sage: F._fricas_init_() == F._giac_init_()                                      
True
sage: giac(F).diff()                                                            
1/2*(-b*(b*x+a)^-2*x+(b*x+a)^-1)*(sqrt((b*x+a)^-1*x))^-1*((b*x+a)^-1*x)^2+2*sqrt((b*x+a)^-1*x)*(-b*(b*x+a)^-2*x+(b*x+a)^-1)*(b*x+a)^-1*x
sage: giac(F).sage()                                                            
x^2*sqrt(x/(b*x + a))/(b*x + a)^2

Last edited 7 months ago by chapoton (previous) (diff)

comment:20 in reply to: ↑ 19 Changed 7 months ago by dimpase

Replying to chapoton:

sorry, but where do you see a missing parenthesis ? The following works fine:

sage: x,a,b = var('x a b')                                                      
sage: F=(x/(b*x+a))^(5/2)                                                       
sage: F._fricas_init_() == F._giac_init_()                                      
True
sage: giac(F).diff()                                                            
1/2*(-b*(b*x+a)^-2*x+(b*x+a)^-1)*(sqrt((b*x+a)^-1*x))^-1*((b*x+a)^-1*x)^2+2*sqrt((b*x+a)^-1*x)*(-b*(b*x+a)^-2*x+(b*x+a)^-1)*(b*x+a)^-1*x
sage: giac(F).sage()                                                            
x^2*sqrt(x/(b*x + a))/(b*x + a)^2

see the output of the debugging print I inserted:

sage: integral(F,x,algorithm="giac")                                                                                                                                                                                                                                              
sage0
sqrt((b*x+a)^-1*x)*((b*x+a)^-1*x)^2
x

there is an attempted conversion to an expression involving sqrt(), but it does not go through!

Where the hell this is happening in the code, I don't know.

comment:21 follow-up: Changed 7 months ago by dimpase

once again: sqrt((b*x+a)^-1*x)*((b*x+a)^-1*x)^2 is what's being passed to giac, and of course this does not fly.

comment:22 Changed 7 months ago by dimpase

Here it is, in another way:

sage: F._giac_()                                                                                                                                                                                                                                                                  
sqrt((b*x+a)^-1*x)*((b*x+a)^-1*x)^2

I don't know where this is happening, but it is obviously very wrong.

by the way

sage: F._fricas_()                                                                                                                                                                                                                                                                
       +-------+
     2 |   x
    x  |-------
      \|b x + a
-------------------
 2 2              2
b x  + 2 a b x + a
Last edited 7 months ago by dimpase (previous) (diff)

comment:23 Changed 7 months ago by frederichan

There is indeed a filter between Expression and giac used to convert some keywords so giac(F) may not be the same as giac(str(F)) I guess it is in sage.symbolic.expression_conversions

comment:24 in reply to: ↑ 21 ; follow-up: Changed 7 months ago by chapoton

Replying to dimpase:

once again: sqrt((b*x+a)^-1*x)*((b*x+a)^-1*x)^2 is what's being passed to giac, and of course this does not fly.

No, I do not think so. This is what giac is printing. What giac gets is the string given by _giac_init_, which is fine.

comment:25 in reply to: ↑ 24 Changed 7 months ago by dimpase

Replying to chapoton:

Replying to dimpase:

once again: sqrt((b*x+a)^-1*x)*((b*x+a)^-1*x)^2 is what's being passed to giac, and of course this does not fly.

No, I do not think so. This is what giac is printing. What giac gets is the string given by _giac_init_, which is fine.

"passing" means "what giac tries to integrate". IMHO it is what Sage prepares to pass to giac, giac is not yet involved at this point.

giac is perfectly capable to take this _giac_init_ and integrate it.

comment:26 Changed 7 months ago by dimpase

meanwhile I looked at Example 8. The trouble there is that giac is highly sensitive to the expression format; we shuffle the terms around, and all of a sudden it has trouble integrating the expression.

0>> integrate((b*x+a)^4*(d*x+c)^3*exp(-b*x-a),x)
^CCtrl-C pressed (pid 21354)
Stopped by user interruption. Error: Bad Argument Value

Evaluation time: 50.4
"Stopped by user interruption. Error: Bad Argument Value"
// Time 50.4
1>> integrate(exp(-b*x-a)*(b*x+a)^4*(d*x+c)^3,x)
Done

and the first of these forms is what you get by doing

sage: F=exp(-b*x-a)*(b*x+a)^4*(d*x+c)^3
sage: F._giac_()

so that's why this particular example is stuck in Sage.

So it's more of a giac problem/bug for this example.

comment:27 Changed 7 months ago by dimpase

Oops, sorry, you're right, Example 2 is more of a giac problem, too (I took that _giac_init_() form):

0>> integrate((((((b)*(x))+(a))^(-1))*(x))^(5/2),x)
Warning, integration of abs or sign assumes constant sign by intervals (correct if the argument is real):
Check [abs(b*x+a)]
^CCtrl-C pressed (pid 32350)

comment:28 Changed 7 months ago by dimpase

  • Report Upstream changed from N/A to Reported upstream. No feedback yet.

comment:29 Changed 7 months ago by dimpase

  • Description modified (diff)

comment:30 Changed 7 months ago by dimpase

  • Description modified (diff)

comment:31 in reply to: ↑ 11 Changed 7 months ago by dimpase

Replying to gh-DaveWitteMorris:

@gh-nasser1: Thanks for reporting this problem. It seems to be serious, but I hope it will have an easy solution.

An easy solution, making sure that giac called from Sage does exactly the same as giac called stanadlone, is to bypass rewriting done by Sage, by using giac.eval(). E.g.

sage: x,a,b,B,A,m,n,d,c = var('x a b B A m n d c')                                                                                                                                           
sage: F='exp(-b*x-a)*(b*x+a)^4*(d*x+c)^3'                                                                                                                                                    
sage: giac.eval(F+',x')                                                                                                                                                                      
'exp(-b*x-a)*(b*x+a)^4*(d*x+c)^3,x'
sage: giac.eval('integrate('+F+',x)')                                                                                                                                                        
'(-x^7*d^3*b^11-4*x^6*...'

So you pass giac a string and get a string back. One can convert strings to Sage's symbolic expressions then, by calling SR().

comment:32 Changed 7 months ago by dimpase

  • Report Upstream changed from Reported upstream. No feedback yet. to Reported upstream. Developers acknowledge bug.

the problem of Ex.8 has been fixed upstream: https://dev.geogebra.org/trac/changeset/69729/

comment:33 Changed 4 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Moving this ticket to 9.4, as it seems unlikely that it will be merged in 9.3, which is in the release candidate stage

comment:34 Changed 3 months ago by slelievre

  • Cc charpent added

Examples 2, 3, 5, 6, 7 have ln in Giac's output. Emmanuel Charpentier's answer to

points to the absence of conversion from Giac's ln to Sage's log being a problem.

comment:35 Changed 5 weeks ago by gh-sheerluck

Note: See TracTickets for help on using tickets.