#16587: f(expr).n() fails for all generalized functions
-----------------------------------+------------------------
       Reporter:  rws              |        Owner:
           Type:  defect           |       Status:  new
       Priority:  major            |    Milestone:  sage-6.4
      Component:  symbolics        |   Resolution:
       Keywords:  sgn, evaluation  |    Merged in:
        Authors:                   |    Reviewers:
Report Upstream:  N/A              |  Work issues:
         Branch:                   |       Commit:
   Dependencies:                   |     Stopgaps:
-----------------------------------+------------------------

Comment (by rws):

 Actually all functions in `generalized.py` show this problem. Moreover,
 the `cos` can be left out:
 {{{
 sage: M = sgn((3/2),hold=True); M.n()
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)
 <ipython-input-18-b9940d9ad473> in <module>()
 ----> 1 M = sgn((Integer(3)/Integer(2)),hold=True); M.n()

 /home/ralf/sage/local/lib/python2.7/site-
 packages/sage/symbolic/expression.so in
 sage.symbolic.expression.Expression._numerical_approx
 (build/cythonized/sage/symbolic/expression.cpp:27093)()

 TypeError: cannot evaluate symbolic expression numerically
 }}}
 All the generalized functions have this code in `_eval_()` and I believe
 the bug to be there:
 {{{
         try:
             approx_x = ComplexIntervalField()(x)
             if bool(approx_x.imag() == 0):      # x is real
                 if bool(approx_x.real() == 0):  # x is zero
                     return ...
                 else:
                     return ...
             else:
                 return ...            # x is complex
         except Exception:                     # x is symbolic
             pass
         return None
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/16587#comment:3>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to