Opened 11 years ago
Closed 10 years ago
#13271 closed defect (fixed)
wrong sign with function Ei and limit
Reported by:  Daniel Krenn  Owned by:  Burcin Erocal 

Priority:  major  Milestone:  sage5.3 
Component:  symbolics  Keywords:  Ei limit sign 
Cc:  Nils Bruin, Benjamin Jones, D.S. McNeil  Merged in:  sage5.3.beta2 
Authors:  KarlDieter Crisman  Reviewers:  Benjamin Jones 
Report Upstream:  N/A  Work issues:  
Branch:  Commit:  
Dependencies:  #11143  Stopgaps: 
Description (last modified by )
We have
sage: (Ei(Z)).limit(Z=oo) Infinity
which is wrong, since it should be 0. It seems that there goes something wrong with the 
sign. This can be also seen here:
sage: (Ei(Z)).limit(Z=1000) Ei(1000) sage: (Ei(Z)).limit(Z=1000).n() 1.97204513714124e431
But
sage: Ei(1000).n() 5.07089306023517e438 sage: Ei(1000).n() 1.97204513714124e431
which are the correct results.
Apply trac_13271Eimaxima.2.patch to Sage library.
Attachments (1)
Change History (13)
comment:1 Changed 11 years ago by
Cc:  Nils Bruin added 

comment:2 Changed 11 years ago by
Or maybe I'm not.
sage.functions.other.Ei : lambda X : [[max_gamma_incomplete], 0, X]
which is here. I was kind of wondering about this in #11143, but since that didn't touch that I figured it was okay. Mathworld seems to indicate that this conversion isn't quite right (where by "isn't quite right" I mean "wrong"), and who knows what this would imply for complex Z
. Yikes.
comment:3 Changed 11 years ago by
Cc:  Benjamin Jones D.S. McNeil added 

comment:4 Changed 11 years ago by
In fact, this makes no sense whatsoever. We should change the two lone references to max_gamma_incomplete
to use the appropriate thing for Ei
instead. This dates from the very start of the ECL conversions at #7377. Unless the Maxima expintegral_ei
is somehow less powerful than the incomplete gamma?
I'm going to try just eliminating all that.
comment:5 Changed 11 years ago by
Huh.
Apply

sage/interfaces/maxima_lib.py
diff git a/sage/interfaces/maxima_lib.py b/sage/interfaces/maxima_lib.py
a b 1165 1165 max_psi=EclObject("$PSI") 1166 1166 max_array=EclObject("ARRAY") 1167 1167 mdiff=EclObject("%DERIVATIVE") 1168 max_gamma_incomplete=sage_op_dict[sage.functions.other.gamma_inc]1169 1168 max_lambert_w=sage_op_dict[sage.functions.log.lambert_w] 1170 1169 1171 1170 def mrat_to_sage(expr): … … 1358 1357 sage.functions.log.polylog : lambda N,X : [[mqapply],[[max_li, max_array],N],X], 1359 1358 sage.functions.other.psi1 : lambda X : [[mqapply],[[max_psi, max_array],0],X], 1360 1359 sage.functions.other.psi2 : lambda N,X : [[mqapply],[[max_psi, max_array],N],X], 1361 sage.functions.exp_integral.Ei : lambda X : [[max_gamma_incomplete], 0, X],1362 1360 sage.functions.log.lambert_w : lambda N,X : [[max_lambert_w], X] if N==EclObject(0) else [[mqapply],[[max_lambert_w, max_array],N],X] 1363 1361 }
to get
sage: var('Z') Z sage: (Ei(Z)).limit(Z=oo) 0 sage: (Ei(Z)).limit(Z=1000) Ei(1000) sage: (Ei(Z)).limit(Z=1000).n() 5.07089306023517e438
Tests look good.
comment:6 Changed 11 years ago by
Authors:  → KarlDieter Crisman 

Dependencies:  → #11143 
In theory, fixing this doesn't need #11143, but might as well do it on that since it's about the same thing.
Oops, still need to add doctests...
comment:7 Changed 11 years ago by
Status:  new → needs_review 

Not that I'm guaranteeing this didn't mess anything else up. But it seems like a better solution overall than keeping the old hack.
comment:8 followup: 10 Changed 11 years ago by
Reviewers:  → Benjamin Jones 

Looks good to me, and nice catch. I think it makes sense to have this ticket depend on 11143 so the doctests can be added to the right place. Hopefully that ticket will make it through the gauntlet soon!
I noticed missing indentation in the doctest block you added. I'll post a quick reviewer patch. If it looks ok to you, I'll set this to positive review.
Changed 11 years ago by
Attachment:  trac_13271Eimaxima.2.patch added 

added indentation to new doctest block
comment:9 Changed 11 years ago by
Description:  modified (diff) 

comment:10 Changed 11 years ago by
I noticed missing indentation in the doctest block you added. I'll post a quick reviewer patch. If it looks ok to you, I'll set this to positive review.
Please do. I can't believe I indented them wrong  that's what happens when you're doing a patch at 11 PM. Thanks for catching this.
comment:11 Changed 11 years ago by
Status:  needs_review → positive_review 

comment:12 Changed 10 years ago by
Merged in:  → sage5.3.beta2 

Resolution:  → fixed 
Status:  positive_review → closed 
Just as a data point, we still get this after #11143, unsurprisingly given that that doesn't touch Maxima.
This is a little weird, since in both Maxima in current Sage and in Maxima 5.27
Further,
Using the Maxima lib version is ok too.
I have a feeling that the following is the problem,
combined with
So somehow this is completely bypassing the symbol table. I am out of my depth in our ECL conversions...