Piecewise defined functions



["Lukasz Stafiniak" , Fri, 21 Jan 2005 12:26:49 +0100]:
> I've started writing a tiny library for functions defined as e.g. [x =
> MINF, -x, x = -2, 2, x = 2, x, x = INF]. But then I've browsed the archive
> and found propositions to use 'boxcars' (U(x - a) - U(x - b)), U(x) = 0 for
> x < 0, 1 for x > 0. What do you think?
> 
> Perhaps writing datatypes for mathematical objects from scratch, when they
> can be encoded in the existing machinery, is no good.

I think you are right: with basically the Heaviside function (I don't
get the "boxcars" reference) you can use just the usual Maxima
functions for everything that does not need to know about the fact
that things are piecewise.

In case you are interested, I have some Maxima code sitting somewhere
(either at this computer or at home) that implements something similar
to the Heaviside function.  Beware, however, that it depends on my
personal Maxima library, and as I see subscripts as a misfeature, a
lot of things may or may not break when you mix any of my code with
subscript-infested expressions.  If I recall correctly, some of the
code for taking limits or for re-writing integrals may not work right
now.  Anyway, let me know in case you want me to send that stuff to
you.

Albert.