Ticket #13271 (closed defect: fixed)
wrong sign with function Ei and limit
| Reported by: | dkrenn | Owned by: | burcin |
|---|---|---|---|
| Priority: | major | Milestone: | sage-5.3 |
| Component: | symbolics | Keywords: | Ei limit sign |
| Cc: | nbruin, benjaminfjones, dsm | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Benjamin Jones |
| Authors: | Karl-Dieter Crisman | Merged in: | sage-5.3.beta2 |
| Dependencies: | #11143 | Stopgaps: |
Description (last modified by benjaminfjones) (diff)
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.07089306023517e-438 sage: -Ei(1000).n() -1.97204513714124e431
which are the correct results.
Apply trac_13271-Ei-maxima.2.patch to Sage library.
Attachments
Change History
comment:2 Changed 10 months ago by kcrisman
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:4 Changed 10 months ago by kcrisman
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 10 months ago by kcrisman
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.07089306023517e-438
Tests look good.
comment:6 Changed 10 months ago by kcrisman
- Dependencies set to #11143
- Authors set to Karl-Dieter Crisman
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 10 months ago by kcrisman
- Status changed from new to 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 follow-up: ↓ 10 Changed 10 months ago by benjaminfjones
- Reviewers set to 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 10 months ago by benjaminfjones
-
attachment
trac_13271-Ei-maxima.2.patch
added
added indentation to new doctest block
comment:10 in reply to: ↑ 8 Changed 10 months ago by kcrisman
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 10 months ago by benjaminfjones
- Status changed from needs_review to positive_review
comment:12 Changed 9 months ago by jdemeyer
- Status changed from positive_review to closed
- Resolution set to fixed
- Merged in set to sage-5.3.beta2

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...