Thanks for this. So, we are trying to convert something like `[(x, x >
0), (-x , x <=0)]` to `[(x, (0, oo) ), (-x, (-oo, 0] ) ]`. I wrote a
small script to try it out for univariate functions
```
def to_expr_set(p, input_set=None):
if input_set is None:
U = Interval(-oo, oo) # U: current universal set
else:
U = input_set
exp_ints = []
for expr, cond in p.args:
cond_int = U.intersect(isolve(cond))
# isolve returns the solution of a relation as Set
U = U - cond_int
exp_ints.append((expr, cond_int))
return exp_ints
```
I guess this transformation will be useful in general, not just for imageset.
After all the work that is being done on Set like SetExpr and
Set.boundary, I think sets will be much more easier to work with than
relations.
For bool->Set transformation I noticed your comment on #2736. But I'll
implement this after we have a more user/developer friendly bool->set
transformation tool which I plan pull out as a part of #2736.
On 7 January 2014 01:36, Matthew Rocklin <[email protected]> wrote:
> A piecewise could be thought of as a list of (Expr, Boolean) pairs. We can
> translate this into a set of (Expr, Set) pairs, intersect each set with the
> set that is input to imageset, apply that particular expr, and then Union
> all of the imagesets together. That may have been a little unclear. To
> make it more explicit consider the following transformation:
>
> imageset(x, Piecewise((expr1, set1), (expr2, set2), (expr3, set3)),
> input_set)
>
> ->
>
> Union(imageset(x, expr1, Intersection(set1, input_set)),
> imageset(x, expr2, Intersection(set2, input_set)),
> imageset(x, expr3, Intersection(set3, input_set)))
>
> In translating the booleans to sets there are good tools in SymPy to help
> with this for any particular bool->set transformation. If you're interested
> in this I can poke around a bit to find them. We'll also have to be careful
> about this transformation because Piecewise booleans are ordered so that the
> first ones take precedence. We'll have to use either set subtraction or
> boolean arithmetic here to remove parts.
>
> Again, I'm not sure how clear this was. Please ask for clarification where
> needed.
>
>
>
> On Sun, Jan 5, 2014 at 11:49 PM, Harsh Gupta <[email protected]>
> wrote:
>>
>> I'm working on improving the imageset evaluation for Intervals on
>> https://github.com/sympy/sympy/pull/2723
>> imagset basically returns the set of possible outputs of a functions
>> given an input set. I want to extend this functionality to piecewise
>> functions.
>> So I want to know if there is a general method to find the critical points
>> of piecewise functions.
>>
>> --
>> Harsh Gupta
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/sympy.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
--
Harsh
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.