Hello, I'm trying to use a piecewise function, and it doesn't seem to work very well. If I do
f = Piecewise([((0, 1), x), ((1, 2), 1)], x) and try to evaluate f(3/2), it complains that Integer objects are not callable. The docstring for Piecewise says "if the optional var is specified, then any symbolic expressions in the list will be converted to symbolic functions using fcn.function(var)" -- shouldn't it also try to convert non-symbolic expressions? I can do SR(1), but I don't want to get into explaining to my students what that means. With the above definition, I also can't easily plot the function: if I do plot(f, 0, 2) I get "ValueError: free variable: x |--> x" and if I do plot(f(x), x, 0, 2) it complains "value not defined outside of domain". The only way I could get the function to plot is with plot(lambda x: f(x), 0, 2) which seems like an unnecessary workaround. If I define the function with f = Piecewise([((0,1), x), ((1,2), SR(1))]) I still have problems; when I try to evaluate f(3/2), it says "the number of arguments must be less than or equal to 0"!? I also can't seem to get diff() to work with this function, even though f.derivative() works. Are these known problems? Am I not using Piecewise properly? Dan -- --- Dan Drake ----- http://mathsci.kaist.ac.kr/~drake -------
signature.asc
Description: Digital signature