possible regression in piecewise plotting?

47 views
Skip to first unread message

kcrisman

unread,
Sep 29, 2016, 1:34:37 PM9/29/16
to sage-support
I am so glad that new piecewise is in, so not complaining - but asking as some notes now do not plot properly.  Example:

P = piecewise([((0,2),x),((2,6),2)])
print P
plot(P)


You can see that it is not only not plotting beyond x=1, it is complaining about negative values.  That says to me that we are now calling the generic plot method, which (when not fed endpoints) by default plots on (x,-1,1).

However, previously plotting piecewise functions by default plotted the entire thing (since they didn't go out to infinity).  I understand the consistency, but also suspect this might have just been overlooked.  Any thoughts?

Thanks!
 - kcrisman

Paul Masson

unread,
Sep 30, 2016, 5:06:33 PM9/30/16
to sage-support
The custom plot() method is not present in the current version of piecewise(). I tried copying it in from piecewise_old.py and rebuilding, but it still gets ignored in favor of the standard plot() (hence the behavior you describe).

I'm not as enthusiastic as you about the current piecewise(). While symbolics are always nice, I think this version is a regression compared to the ease of use of the corresponding Piecewise[] in Mathematica. I'd certainly like to see improvements to make it more like Mathematica's version.

If you'd like to open a ticket to address the missing custom plot, I'd be interested in fixing the problem.

kcrisman

unread,
Sep 30, 2016, 10:39:42 PM9/30/16
to sage-support


I'm not as enthusiastic as you about the current piecewise(). While symbolics are always nice, I think this version is a regression compared to the ease of use of the corresponding Piecewise[] in Mathematica.

Well, technically speaking it's only a regression if it's worse than the corresponding previous Sage - which I assume it's not, since one can actually do things with it.
 
I'd certainly like to see improvements to make it more like Mathematica's version.


Of course!  Unfortunately the Maxima piecewise.mac never got seriously looked at, though I suspect it has gaps as well.
 
If you'd like to open a ticket to address the missing custom plot, I'd be interested in fixing the problem.


Sure, if you have a chance (I worked around it by just setting the endpoints): https://trac.sagemath.org/ticket/21618

Ralf Stephan

unread,
Oct 5, 2016, 9:44:29 AM10/5/16
to sage-support
On Thursday, September 29, 2016 at 7:34:37 PM UTC+2, kcrisman wrote:
P = piecewise([((0,2),x),((2,6),2)])
print P
plot(P)

However, previously plotting piecewise functions by default plotted the entire thing (since they didn't go out to infinity).  I understand the consistency, but also suspect this might have just been overlooked.  Any thoughts?

It has been overlooked because the only plotting doctest has x in (-1,1).
Reply all
Reply to author
Forward
0 new messages