Hi, Another strange behavoir:
sage: f=Piecewise([[(1/3,1/2),x]]) sage: f.extend_by_zero_to(0,1) Piecewise defined function with 3 parts, [[(0, 1/3), 0], [(1/3, 1/2), x], [(1/2, 1), 0]] sage: f.domain() (1/3, 1/2) extend_by_zero shouldn't have changed the domain to (0,1) ? sage: f.integral() Piecewise defined function with 1 parts, [[(1/3, 1/2), x |--> 1/2*x^2 - 1/18]] f.integral also forgets about the extension by zero? sage: f.derivative() /media/sdb3/pablo.sdb3/sage/sage-6.3-x86_64-Linux/src/bin/sage-ipython:1: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details. #!/usr/bin/env python Piecewise defined function with 1 parts, [[(1/3, 1/2), x |--> 1]] A bit annoying message, not? Pablo On Mon, Feb 16, 2015 at 10:46 AM, Pablo De Napoli <pden...@gmail.com> wrote: > Hi, > > I'm having trouble with some piecewise constant functions. > > Suppose that I define > > f=Piecewise ([([0,1],0),([1,2],x-1)]) > > Then f.integral() works as expected, but f.derivative() will fail with > > TypeError: 'sage.rings.integer.Integer' object is not callable > > It seems that Sage does not understand that 0 is the null function, > and treat it as an integer for with a derivative is not meaningful > > Then, I've tried defining > > f1=Piecewise ([([0,1],ConstantFunction(0)),([1,2],x-1)]) > > f1.derivative() now works and one would expect, but > f1.integral() fails with a TypeError > > My last try was to cast 0 to the symbolic ring > > f2=Piecewise ([([0,1],SR(0)),([1,2],x-1)]) > > Now f2.integral() works, but f2.derivative() fails with the error message > > ValueError: the number of arguments must be less than or equal to 0 > > Whats the right way to define my function so that both integral and > derivative work ? The behavior of Sage is annoying ! Any help is > welcome! > > best regards > Pablo -- 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 http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.