piecewise function with integrals



"I'm sympathetic with the idea but there is an issue to note ..."


On 1/20/2013 2:44 PM, Henry Baker wrote:
> I'd be happy with a relatively simplistic form of if-then-else 
> expressions, which could do "simplifications"/transformations like this:
>
> a*(if ... then b else c) <=> (if ... then a*b else a*c)
>
> a+(if ... then b else c) <=> (if ... then a+b else a+c)
>
> etc.

This has already been thought through and done in pw.mac.

(%i7) display2d:false;
(out7) false
(%i8) (1/(x-1) *  if equal(x,1) then 1 else (x-1));
(out8) (if equal(x,1) then 1 else x-1)/(x-1)
(%i9) ifthen2iif(%);  /* convert. iif supports context sensitive 
simplifications */
(out9) iif(equal(x,1),1,x-1)/(x-1)
(%i10) pulliniif(%); /* combine */
(out10) iif(equal(x,1),1/(x-1),1)
(%i11) iif2ifthen(%); /* convert back, no divide by zero in this case */
(out11) if equal(x,1) then 1/(x-1) else 1

Maybe someone could look at the source code for how it works and how it 
fails in various cases.
Rich