On Tuesday, January 28, 2014 8:29:16 PM UTC-5, Robert Jacobson wrote:
>
> I am having difficulty using Piecewise(). For example, I can define the 
> following:
> t = Piecewise([[(-oo, -1), 0*x^0], [(-1, 0), 1+x], [(0, 1), 1-x], [(1, oo
> ), 0*x^0]], x)
> but then evaluating t(-100) fails.
>

Hmm, this works for me.  What version of Sage are you using?

 

> I can modify the above to have a finite domain:
> t = Piecewise([[(-10, -1), 0*x^0], [(-1, 0), 1+x], [(0, 1), 1-x], [(1, 10
> ), 0*x^0]], x)
> This seems to evaluate correctly within its domain, but I can't plot it, 
> say, with this (or variations thereof):
> plot(t(x), x, -4, 4)
>
>
Piecewise is an amalgam of some very old code/methods and some other stuff. 
 Consequently, one has to read its documentation fairly carefully to see 
what might need to be done.  See http://trac.sagemath.org/ticket/11225 for 
just some of the quirks. 

In this case, you need to plot

sage: plot(t).show(xmin=-4,xmax=4)

because rather than plotting t, it calls t.plot and that changes things 
quite a bit.  Also 

sage: t(x)
ValueError: ...

since Piecewise objects are still not symbolic.

I'm sorry this is still the case. 
  See http://trac.sagemath.org/ticket/14801 for a prototype for a new way 
to do all this.  Luckily, you should be able to do what you want, but not 
with a unified syntax, it is true.

- kcrisman

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to