Re: piecewise functions from logical relationships (ie. solving with constraints)

*To*: mathgroup at smc.vnet.net*Subject*: [mg81296] Re: piecewise functions from logical relationships (ie. solving with constraints)*From*: Benjamin.R.Lewis at gmail.com*Date*: Tue, 18 Sep 2007 05:57:57 -0400 (EDT)*References*: <fclb12$fdk$1@smc.vnet.net><fcnk67$rnl$1@smc.vnet.net>

> I dunno how you made Reduce give you that answer (I didn't try very > long), but, since you have it: > > In[1]:= (x==2/5+y&&-2/5<y<1/2)||(x==7/5+y&&-1/2<y<-2/5)/.{Or->List,And[Equal[l_,r_],cond_]:>(l/;cond->r)} > > Out[1]= {x/;-(2/5)<y<1/2->2/5+y,x/;-(1/2)<y<-(2/5)->7/5+y} I'm reluctant to try to "parse" the expression myself because (since my package won't know the equations and constraints in advance) I don't know what guarantees exist on the form of the output. With respect, but as an example of how easily I might overlook some further possibility: your solution requires a particular ordering of terms (which appears to be version dependent at best), that the constraint is non-empty, and that the condition on an individual part never contains Or. I would have thought this would be a fairly common problem; can't Mathematically automatically re-express these somehow?