Thats the expected output since 1 is not in the domain: sage: f.domain() (0, 1) + (1, 3) + (3, 4)
You probably want sage: g = piecewise([[(0,1),x], [[1,3],2-x], [(3,4),x-4]]) sage: g.domain() (0, 4) sage: g.plot([0,4]) On Sunday, May 22, 2016 at 12:06:27 AM UTC+2, paulmasson wrote: > > Since the SageMathCell server has been updated to Sage 7.2, I've been > experiencing issues with piecewise functions. For example, define a simple > saw tooth with > > f=piecewise([[(0,1),x],[(1,3),2-x],[(3,4),x-4]]) > > The endpoints appear to be defined just fine, > > f.end_points() > > [0, 1, 3, 4] > > > but if I evaluate f(1) I get this message: > > > --------------------------------------------------------------------------- > ValueError Traceback (most recent call last) > <ipython-input-1-3e93894c0576> in <module>() > 2 #show(plot(f)) > 3 f.end_points() > ----> 4 f(Integer(1)) > > /home/sc_serv/sage/local/lib/python2.7/site-packages/sage/symbolic/function_factory.pyc > in new_f(ex, *args, **kwds) > 400 new_args = list(ex._unpack_operands()) > 401 new_args.extend(args) > --> 402 return f(ex, *new_args, **kwds) > 403 return new_f > > /home/sc_serv/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py > in __call__(cls, self, parameters, variable, value, **kwds) > 447 if value is not None: > 448 substitution[variable] = value > --> 449 return self.subs(substitution) > 450 > 451 def _fast_float_(cls, self, *args): > > /home/sc_serv/sage/src/sage/symbolic/expression.pyx in > sage.symbolic.expression.Expression.substitute > (/home/sc_serv/sage/src/build/cythonized/sage/symbolic/expression.cpp:27845)() > 4883 > 4884 return new_Expression_from_GEx(self._parent, > -> 4885 self._gobj.subs_map(smap, 0)) > 4886 > 4887 subs = substitute > > /home/sc_serv/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py > in _subs_(self, subs_map, options, parameters, x) > 228 if domain.contains(point): > 229 return subs_map.apply_to(func, 0) > --> 230 raise ValueError('point {} is not in the > domain'.format(point)) > 231 > 232 @staticmethod > > ValueError: point 1 is not in the domain > > > Adding decimal points to the endpoints to coerce them to float values > doesn't fix the problem. > > Sage 7.2 includes http://trac.sagemath.org/ticket/14801 that is supposed > to fix problems with symbolics. Am I missing some new behavior or is this a > bug? > > -- 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.