Piecewise defined functions



There is a unit step function in orthopoly; here is a link to the user 
documentation and
the source code

http://www.unk.edu/acad/math/people/willisb/orthopoly_doc.html
http://www.unk.edu/acad/math/people/willisb/

(%i1) load("l:/orthopoly-0.94/orthopoly")$
(%i2) unit_step(0);
(%o2)                                         0
(%i3) unit_step(x);
(%o3)                                    unit_step(x)
(%i4) subst(x=1,%);
(%o4)                                         1
(%i5) f(x) := (unit_step(x) - unit_step(x-5)) * x;
(%o5)                    f(x) := (unit_step(x) - unit_step(x - 5)) x
(%i6) f(0);
(%o6)                                         0
(%i7) f(3/7);
(%o7)                                         3 / 7
(%i8) f(4.99);
(%o8)                                        4.99
(%i9) f(4.99b0);
(%o9)                                       4.99B0
(%i10) f(5);
(%o10)                                        5
(%i11) f(5.1);
(%o11)                                        0
(%i12) f(x+y);
(%o12)                (y + x) (unit_step(y + x) - unit_step(y + x - 5))
(%i13) plot2d(f(x),[x,-7,7]);
(%o13) 
(%i14) assume(a > 5);
(%o14)                                     [a > 5]
(%i15) f(a);
(%o15)                                        0
(%i16) assume(b > 0, b < 5);
(%o16)                                  [b > 0, b < 5]
(%i17) f(b);
(%o17)                                        b
(%i18) 

Barton