#11143: define symbolic functions for exponential integrals
--------------------------------------------------+-------------------------
   Reporter:  kcrisman                            |          Owner:  
benjaminfjones                    
       Type:  defect                              |         Status:  new        
                       
   Priority:  major                               |      Milestone:  sage-4.7.2 
                       
  Component:  symbolics                           |       Keywords:  ei Ei 
special function maxima sd32
Work_issues:                                      |       Upstream:  N/A        
                       
   Reviewer:  Burcin Erocal, Karl-Dieter Crisman  |         Author:  Benjamin 
Jones                    
     Merged:                                      |   Dependencies:  #11513     
                       
--------------------------------------------------+-------------------------

Comment(by benjaminfjones):

 Trying to finish up the patch, I've run into a problem evaluating any of
 my new functions at python floats. For example, apply the patch and try:

 {{{
 sage: exp_integral_e1(float(1))
 ERROR: An unexpected error occurred while tokenizing input
 The following traceback may be corrupted or invalid
 The error message is: ('EOF in multi-line statement', (690, 0))

 ---------------------------------------------------------------------------
 AttributeError                            Traceback (most recent call
 last)

 /Users/jonesbe/sage/sage-4.7.2.alpha2/devel/sage-test/sage/<ipython
 console> in <module>()

 /Users/jonesbe/sage/latest/local/lib/python2.6/site-
 packages/sage/symbolic/function.so in
 sage.symbolic.function.Function.__call__
 (sage/symbolic/function.cpp:4599)()

 /Users/jonesbe/sage/latest/local/lib/python2.6/site-
 packages/sage/functions/exp_integral.pyc in _eval_(self, z)
     335         """
     336         if not isinstance(z, Expression) and is_inexact(z):
 --> 337             return self._evalf_(z, parent(z))
     338
     339         return None # leaves the expression unevaluated

 /Users/jonesbe/sage/latest/local/lib/python2.6/site-
 packages/sage/functions/exp_integral.pyc in _evalf_(self, z, parent)
     350         """
     351         import mpmath
 --> 352         return mpmath_utils.call(mpmath.e1, z, parent=parent)
     353
     354     def _derivative_(self, z, diff_param=None):

 /Users/jonesbe/sage/latest/local/lib/python2.6/site-
 packages/sage/libs/mpmath/utils.so in sage.libs.mpmath.utils.call
 (sage/libs/mpmath/utils.c:5277)()

 AttributeError: type object 'float' has no attribute 'prec'
 }}}

 You also get the error if you try to plot any of the exponential integral
 functions as they are written unless you wrap the input with `RDF` or
 something similar.

 The error is being raised inside the `call` function in
 `sage/libs/mpmath/util.pyx`. I've looked through that code and thought
 about what would happen if the `prec` option is not specified (as in my
 code) and the parent is `None` (as when a python float is passed), but I
 can't figure out why it doesn't work to pass a float.

 On the other hand, changing the lines in the `_evalf` method

 {{{
 import mpmath
 return mpmath_utils.call(mpmath.e1, z, parent=parent)
 }}}

 to

 {{{
 import mpmath
 if isinstance(parent, Parent) and hasattr(parent, 'prec'):
     prec = parent.prec()
 else:
     prec = 53
 return mpmath_utils.call(mpmath.si, z, prec=prec)
 }}}

 fixes the error.

 What do people think? Is this a bug in the `call` function (which claims
 it will accept any type that mpmath handles natively like python floats)
 or is there something wrong with my code?

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11143#comment:24>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to