Piecewise Function: endpoint gotcha - bug or feature? It seems that the piecewise function (which requires overlapping endpoints for the specified function intervals) does some unadvertised averaging for results for values at the endpoints.
See the sage output from the input below. Rather than pick one of the function intervals for the result - it seems to average the two Nothing jumped out at me in the documentation on this matter. Is there a way to force the piecewise function to use the function result from the upper or lower function interval when at an interval boundary? INPUT: #This code defines a piecewise function which is -1 below pi/2 and 2 above pi/2. f1(x) = -1 f2(x) = 2 fp = Piecewise([[(0,pi/2),f1],[(pi/2,pi),f2]]) # When pi/2 is put into the function, it averages the two results from the adjoining function definitions. # just above and just below the interval boundary the results are correct. dn=0.000001 # some small interval for n in [-dn,0,dn]: print "fp(pi/2 + ",n,")= ",fp(pi/2+n) OUTPUT: fp(pi/2 + -1.00000000000000e-6 )= -1 fp(pi/2 + 0 )= 1/2 fp(pi/2 + 1.00000000000000e-6 )= 2 --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---