Another problem I've encountered concerns including numerical integrals in 
piecewise functions. This used to work in Sage 6.9:

def g(x):
    var('u')
    return numerical_integral(u^2,0,x)[0]

f=piecewise([ [(0,1), g ] ])

but now gives the error message


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-d490d0695d4b> in <module>()
      4 
      5 
----> 6 f=piecewise([ [(Integer(0),Integer(1)), g ] ])
      7 

/home/sc_serv/sage/src/sage/misc/lazy_import.pyx in 
sage.misc.lazy_import.LazyImport.__call__ 
(/home/sc_serv/sage/src/build/cythonized/sage/misc/lazy_import.c:3628)()
    384             True
    385         """
--> 386         return self._get_object()(*args, **kwds)
    387 
    388     def __repr__(self):

/home/sc_serv/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py
 in __call__(self, function_pieces, **kwds)
    149                     function = function()
    150                 else:
--> 151                     function = function(var)
    152             function = SR(function)
    153             if var is None and len(function.variables()) > 0:

<ipython-input-1-d490d0695d4b> in g(x)
      1 def g(x):
      2     var('u')
----> 3     return numerical_integral(u**Integer(2),Integer(0),x)[Integer(0)]
      4 
      5 

/home/sc_serv/sage/src/sage/gsl/integration.pyx in 
sage.gsl.integration.numerical_integral 
(/home/sc_serv/sage/src/build/cythonized/sage/gsl/integration.c:3387)()
    329       else:
    330          _a=a
--> 331          _b=b
    332          W = <gsl_integration_workspace*> 
gsl_integration_workspace_alloc(n)
    333          sig_on()

/home/sc_serv/sage/src/sage/symbolic/expression.pyx in 
sage.symbolic.expression.Expression.__float__ 
(/home/sc_serv/sage/src/build/cythonized/sage/symbolic/expression.cpp:10403)()
   1384             return float(self._eval_self(float))
   1385         except TypeError:
-> 1386             raise TypeError("unable to simplify to float approximation")
   1387 
   1388     def __complex__(self):

TypeError: unable to simplify to float approximation


which makes no sense since a numerical integral is already a float. Is 
there some other new behavior I'm missing?

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to