Integrating function with abs or max



On 1/22/07, Ray Tice <trayracing at yahoo.com> wrote:

> How do I reformulate functions that use abs or max so that maxima can
> integrate them?

Ray, thanks for the inspiration, but for better or worse I didn't really
get very far on this yet. If anyone has comments on this stuff I
would be interested to hear about it.

There are some related problems here -- moving conditionals from
integrands into limits of integration; allowing arithmetic and other
operations on conditionals; and simplifying Boolean expressions
when some clauses imply or rule out others.

I made some sketchy progress on the stuff about operations on
conditionals (although not the other two items). For your consideration,
here's an example:

mymax(a,b) := if a>b then a else b;
myabs(x) := if x<0 then -x else x;
F(x) := mymax(1 - myabs(x), 0);
F(x);
  => -(if 1-(if x < 0 then -x else x) > 0
            then 1-(if x < 0 then -x else x) else 0

Then simplifying it with some rules about how to flatten it --

  => if (x < 0 and x+1 > 0 or x >= 0 and 1-x > 0) and x < 0
          then x+1
          elseif (x < 0 and x+1 > 0 or x >= 0 and 1-x > 0)
           and x >= 0 then 1-x else 0

The relational expressions can obviously be simplified, I just
haven't worked on that part yet.

F(x)*F(1 - x) yields a rather long expression --

 if (1-x < 0 and 2-x > 0 or 1-x >= 0 and x > 0)
            and 1-x < 0
            and (x < 0 and x+1 > 0 or x >= 0 and 1-x > 0)
            and x < 0 then (2-x)*(x+1)
           elseif (1-x < 0 and 2-x > 0 or 1-x >= 0 and x > 0)
            and 1-x < 0
            and (x < 0 and x+1 > 0 or x >= 0 and 1-x > 0)
            and x >= 0 then (1-x)*(2-x) ....

but this mess does have the advantage that all of the predicates
are at the top level (instead of being nested) so I think it should
be straightforward to extract them for the purpose of modifying
limits of integration and so on.

There's a lot of work to be done here, but it would be worth
it because functions defined by if--then--else are very common
in applications. Hope these meager results can help us get
the wheels turning.

best,
Robert Dodier