On Tue, Oct 27, 2009 at 10:55 AM, all_thumbs <sch...@hsva.de> wrote:
> Hi Dave,
>
> On Jul 22, 12:56 am, David Joyner <wdjoy...@gmail.com> wrote:
> ...
>> I'm not sure what you are going to do with yourfunction.
>> If it is just for plotting, say, I think you might just want to use
>>
>> def f(x,y):
>>     if <case1>:
>>        return <whatever1>
>>     if <case2>:
>>        return <whatever2>
>>    etc



>
> I have recently installed SAGE in the hope that I can cut down a bit
> on
> all the odd math tools that I use today. One of the very first things
> I tried,
> inspired by the calculus quick reference page, was the piecewise
> function.
>
> I quickly found out that a (very simple) function f defined with
> piecewise
> cannot be plotted with "plot(f, ....)", but works fine with "f.plot
> ()". On the
> other hand, the same function defined as a python function as above,
> does not plot properly. Oddly enough, when I define abs(x) like this:
>
> def f(x):
>   if x < 0 :
>      return -x
>   else :
>      return x
>
> only the last branch of the conditional statement is visible in the
> diagram.
> On the other hand, this branch is visible for all input values, x<0
> too!

You could try:

sage: f = lambda x: x > 0 and 1 or -1
sage: plot(f,x,-2,2)


>
> So, even if only need to plot a function, SAGE seems to have some
> troubles with functions that are defined in pieces.
>


Yes, the Piecewise class was written some time ago and badly
needs revision. Hopefully someone will volunteer to work on it more.


> Johannes

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to