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

Add doctest for integrating exp(t)/(t + 1)^2 with giac #25626

Closed
nasser1 opened this issue Jun 21, 2018 · 22 comments
Closed

Add doctest for integrating exp(t)/(t + 1)^2 with giac #25626

nasser1 opened this issue Jun 21, 2018 · 22 comments

Comments

@nasser1
Copy link

nasser1 commented Jun 21, 2018

This ticket is to add a doctest:

sage: t = SR.var('t')
sage: integrate(exp(t)/(t + 1)^2, t, algorithm="giac")
(t*Ei(t + 1) + Ei(t + 1) - e^(t + 1))/(t*e + e)

[Original report]

Using sage 8.3.beta6:

sage: var('t')
sage: integrate(exp(t)/(t + 1)^2, t, algorithm="giac")
undef

whereas used directly, giac integrates with no problem:

>giac
// Using locale /usr/share/locale/
// en_US.utf8
// /usr/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 8
Help file /usr/share/giac/doc/en/aide_cas not found
Added 26 synonyms
Welcome to giac readline interface
(c) 2001,2017 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)
-------------------------------------------------
0>> integrate(exp(t)/(t + 1)^2, t)
 (t*Ei(t+1)+Ei(t+1)-exp(1)*exp(t))/(t*exp(1)+exp(1))
// Time 0.01
1>>

So why did Sage return undef for this computation?

First time reporting bug to Sage.

CC: @frederichan-IMJPRG @sagetrac-parisse @rwst @slel

Component: interfaces

Keywords: giac, integral

Author: Rajat Sirohi

Branch: cdae633

Reviewer: Kwankyu Lee

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

@nasser1 nasser1 added this to the sage-8.3 milestone Jun 21, 2018
@slel
Copy link
Member

slel commented Sep 19, 2018

comment:1

Regarding the bug: maybe the Ei in the result could not be converted to Sage?

Regarding the Trac ticket: not sure if this belongs to "interfaces" or "symbolics".

Was this fixed in another ticket? This is what I get with Sage 8.3.rc3:

sage: version()
'SageMath version 8.3.rc3, Release Date: 2018-07-28'
sage: t = SR.var('t')
sage: integrate(exp(t)/(t + 1)^2, t, algorithm="giac")
integrate(e^t/(t + 1)^2, t)

@slel

This comment has been minimized.

@slel slel changed the title intergrate with giac returns undef integrate with giac returns undef Sep 19, 2018
@slel slel modified the milestones: sage-8.3, sage-8.4 Sep 19, 2018
@slel
Copy link
Member

slel commented Sep 19, 2018

comment:2

Oh, I see, instead of undef I got the unevaluated integral back.

Slightly better than undef, but if Giac can compute it we would like to get the evaluated result.

@mkoeppe mkoeppe modified the milestones: sage-8.4, sage-9.2 Aug 17, 2020
@fchapoton
Copy link
Contributor

comment:4

Giac does the following

giac: integrate(exp(t)*(t+1)^-2,t)                                              
integrate(exp(1/(t+1)^-1-1)*(t+1)^-2,t)
giac: integrate(exp(t)/(t+1)^2,t)                                               
(t*Ei(t+1)+Ei(t+1)-exp(1)*exp(t))/(t*exp(1)+exp(1))

@frederichan-IMJPRG
Copy link

comment:5

NB: it seems that it is not giac himself that is changing the quotient to a product but the conversion filter called before using giac:

sage: t=var('t')                                                                                              
sage: F=exp(t)/(1+t)^2                                                                                        
sage: giac(F)                                                                                                 
(t+1)^-2*exp(t)
sage: giac(str(F))                                                                                            
exp(t)/(t+1)^2
sage: giac(str(F)).integrate(t)                                                                               
(t*Ei(t+1)+Ei(t+1)-exp(1)*exp(t))/(t*exp(1)+exp(1))

@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Oct 24, 2020
@fchapoton
Copy link
Contributor

comment:7

Well, the expression itself is not considered as a quotient in sage:

sage: t = SR.var('t')                                                           
sage: F = exp(t)/(t + 1)^2                                                      
sage: F.operands()                                                              
[(t + 1)^(-2), e^t]
sage: F.operator()                                                              
<function mul_vararg at 0x7f4b14362310>

@slel
Copy link
Member

slel commented Dec 13, 2020

comment:8

I don't think Sage's symbolic expressions are ever
recorded as differences or quotients, only as sums
(summing the opposite for a difference) and products
(multiplying by the inverse for a quotient).

@slel
Copy link
Member

slel commented Mar 27, 2021

comment:9

In Sage 9.3.rc0:

sage: t = SR.var('t')
sage: integrate(exp(t)/(t + 1)^2, t, algorithm="giac")
(t*Ei(t + 1) + Ei(t + 1) - e^(t + 1))/(t*e + e)

Probably one of the giac or giacpy_sage upgrades solved that.

Should we add a doctest?

@slel

This comment has been minimized.

@slel slel changed the title integrate with giac returns undef Add doctest for integrating exp(t)/(t + 1)^2 with giac Mar 27, 2021
@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 7, 2021

comment:11

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Apr 7, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Aug 22, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@fchapoton
Copy link
Contributor

Changed keywords from giac to giac, integral

@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 7, 2022
@Rajat-Sirohi
Copy link

@Rajat-Sirohi
Copy link

New commits:

cdae633Trac #25626: Add doctest for integrating exp(t)/(t + 1)^2 with giac

@Rajat-Sirohi
Copy link

Author: Rajat Sirohi

@Rajat-Sirohi
Copy link

Commit: cdae633

@kwankyu
Copy link
Collaborator

kwankyu commented Apr 19, 2022

comment:18

Perfect.

@kwankyu
Copy link
Collaborator

kwankyu commented Apr 19, 2022

Reviewer: Kwankyu Lee

@kiwifb
Copy link
Member

kiwifb commented May 24, 2022

comment:19

Well, with giac 1.9 which has just been allowed from the system I get

sage -t --long --random-seed=138683552333987748337622634611718883378 /usr/lib/python3.10/site-packages/sage/calculus/calculus.py
**********************************************************************
File "/usr/lib/python3.10/site-packages/sage/calculus/calculus.py", line 387, in sage.calculus.calculus
Failed example:
    integrate(exp(t)/(t + 1)^2, t, algorithm="giac")
Expected:
    (t*Ei(t + 1) + Ei(t + 1) - e^(t + 1))/(t*e + e)
Got:
    ((t + 1)*(1/(t + 1) - 1)*Ei(-(t + 1)*(1/(t + 1) - 1) + 1) - Ei(-(t + 1)*(1/(t + 1) - 1) + 1) + e^(-(t + 1)*(1/(t + 1) - 1) + 1))/((t + 1)*(1/(t + 1) - 1)*e - e)

I haven't really checked whether it can be simplified to the previous form or not.

@Rajat-Sirohi
Copy link

comment:20

Replying to @kiwifb:

Well, with giac 1.9 which has just been allowed from the system I get

sage -t --long --random-seed=138683552333987748337622634611718883378 /usr/lib/python3.10/site-packages/sage/calculus/calculus.py
**********************************************************************
File "/usr/lib/python3.10/site-packages/sage/calculus/calculus.py", line 387, in sage.calculus.calculus
Failed example:
    integrate(exp(t)/(t + 1)^2, t, algorithm="giac")
Expected:
    (t*Ei(t + 1) + Ei(t + 1) - e^(t + 1))/(t*e + e)
Got:
    ((t + 1)*(1/(t + 1) - 1)*Ei(-(t + 1)*(1/(t + 1) - 1) + 1) - Ei(-(t + 1)*(1/(t + 1) - 1) + 1) + e^(-(t + 1)*(1/(t + 1) - 1) + 1))/((t + 1)*(1/(t + 1) - 1)*e - e)

I haven't really checked whether it can be simplified to the previous form or not.

In fact, when you simplify the second expression, it is indeed equivalent to the first.

@vbraun
Copy link
Member

vbraun commented May 24, 2022

@kiwifb
Copy link
Member

kiwifb commented Jun 21, 2022

comment:22

Follow up at #34037

@kiwifb
Copy link
Member

kiwifb commented Jun 21, 2022

Changed commit from cdae633 to none

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

9 participants