Plotting Piece-wise Functions?

21 views
Skip to first unread message

Chris Maness

unread,
Jul 10, 2014, 9:42:49 AM7/10/14
to sage-s...@googlegroups.com
I am not certain why this does not work:
f1=x*e^(-x);
f2=x*e^x;
f=Piecewise([[(0,5),f1],[(0,-5),f2]]);
plot(f,x,-5,5)

Any suggestions?

Thanks,
Chris

Chris Maness

unread,
Jul 10, 2014, 9:51:23 AM7/10/14
to sage-s...@googlegroups.com
I got it. I see that I am not supposed to but limits in the plot
function. The limits of the piecewise function provide that
information.

This works:

f1=x*e^x;
f2=x*e^(-x);
f=Piecewise([[(-5,0),f1],[(0,5),f2]]);
f.plot()

Chris
Reply all
Reply to author
Forward
0 new messages