On Friday, March 4, 2016 at 10:52:58 AM UTC-8, Michael Orlitzky wrote:
>
> But, proposing that we get rid of symbolic expressions in piecewise 
> functions is stronger than the proposal to get rid of unnamed arguments. 
> This works, and accounts for just about every use of piecewise() you'll 
> find, even the ones in the Sage library: 
>
>   sage: f = piecewise([[(-1,1),x]]) 
>   sage: f.plot() 
>
> The proposal would require, 
>
>   sage: f = piecewise([[(-1,1), x.function(x)]]) 
>
> which is a little weird and not used anywhere that I've seen.


I think it suggests the proper solution is having one of two things:

 - piecewise expressions, where we'd need to specify to which variable the 
condition (belonging to an interval) applies. That basically means we'd 
need to be able to pass expressions involving conditionals (perhaps only a 
limited kind) through the symbolic machinery.
 - a way of specifying a piecewise function *using expressions*, i.e., 
something along the lines of

piecewise([[(-1,1),x],[(1,2),x^2]],arguments=(x,))

as a replacement for

piecewise([[(-1,1),x.function(x)],[(1,2),(x^2).function(x)]])

note that the present situation allows for

piecewise([[(-1,1),x],[(1,2),y^2])

which I think is worth getting rid of. There needs to be some indication 
somewhere in what way the interval relates to the variables in the 
expression.

Some other 
> odd cases that I ran into were, 
>
>   f = cos(x).function(x) 
>

f = cos

would do. 

  f = SR(1).function(x) 
>

That only looks funny because of the method notation. If you write this in 
a functional way:

f = symbolic_function(x,1)

it's not nearly as weird. (It's basically "lambda x: 1" which is a 
perfectly fine way of defining a constant function).

It would be nice to use "function" for this, but that's unfortunately a 
namespace clash.

But overall I agree that forcing piecewise() to take functions creates a 
> better mental model. It just may be harder to get rid of than the 
> unnamed-argument function call syntax alone. 
>

I think something along the lines of

piecewise(x, [[(-1,1),x],[(1,2),x^2]])

might be a better compromise then. On the other hand, having

piecewise([[(-1,1),sin],[(1,2),cos]])

 makes perfect sense too, so one would have to think carefully about the 
best calling interface to allow for both.

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

Reply via email to