I'm having trouble with some piecewise constant functions.
Suppose that I define
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
My last try was to cast 0 to the symbolic ring
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
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=...,
See http://trac.sagemath.org/5930 for details.
Piecewise defined function with 1 parts, [[(1/3, 1/2), x |--> 1]]
A bit annoying message, not?
Writing something like
is not what most mathematicians or students would do, I guess. Maybe
there is something to improve here.
I believe the solution of Nils using SR(0) is very elegant, but it cannot be applied in every case. For example, when the piecewise is created by another method (trapezoid):
Here t has a constant part in (-1/3,1/3):
So t(0.1) gives the following error: