unit_step (was Re: New piecewise package in development)



Does this mean that I should use signum instead of unit_step in the pw.mac package?  If it does I thank you for making 
up my mind for me, because I have no idea what way is best given all these considerations.

I like for pw.mac unit_step(x):=(signum(x) + 1)/2 because of it's applications to Fourier.  So pwsumify will look like 
this.

pwsumify(expr):=block
(
    [__i,__retval],
    if matrixp(expr) and length(expr[1]) = 4 then
    (
           retval:sum(expr[i,4]*((signum(expr[i,1]-expr[i,2])+1)/2-(signum(expr[i,1]-expr[i,3])+1)/2), i, 1, 
length(expr))
    )
    else
        retval:0
)$

I have to test to make sure I translated this right but some quick testing shows that I got it right.

Rich



>Also, I believe that the orthogonal polynomial package has a "unit_step"
>function, though I don't know whether its left-continuous nature is
>compatible with what you need.

Maybe unit_step in orthopoly should be changed to exclusively use
signum. Otherwise, we get too many related functions with non-local
simplifications. Something like (lightly tested):


unit_step_right_continuous(x) := block([s : signum(x)], s *(1-s) / 2 + 1);

unit_step_left_continuous(x) := block([s : signum(x)], s * (1 + s) / 2);

unit_ramp(x) := (x + abs(x))/2;

unit_blip(x) := block([s : signum(x)], (1 + s) * (1 - s));

unit_pulse(x, left ,right) :=
  if is(left = 'open) then (
     if is(right = 'open) then unit_step_left_continuous(x) -
     unit_step_right_continuous(x-1)
     else if right = 'closed then unit_step_left_continuous(x) -
     unit_step_left_continuous(x-1)
     else error("The third argument to unit_pulse must be closed or open"))
  else if is(left = 'closed) then (
    if is(right = 'open) then unit_step_right_continuous(x) -
    unit_step_right_continuous(x-1)
    else if right = 'closed then unit_step_right_continuous(x) -
    unit_step_left_continuous(x-1)
    else error("The third argument to unit_pulse must be closed or open"))
  else error("The second argument to unit_pulse must be closed or open");


Short test:

 (%i78) map(lambda([s], unit_pulse(s, 'closed, 'open)),[0,1]);
 (%o78) [1,0]

 (%i79) map(lambda([s], unit_pulse(s, 'closed, 'closed)),[0,1]);
 (%o79) [1,1]

 (%i80) map(lambda([s], unit_pulse(s, 'open, 'open)),[0,1]);
 (%o80) [0,0]

 (%i81) map(lambda([s], unit_pulse(s, 'open, 'closed)),[0,1]);
 (%o81) [0,1]

 (%i82) unit_step_left_continuous(0);
 (%o82) 0

 (%i83) unit_step_right_continuous(0);
 (%o83) 1

 (%i84) map('unit_blip, [-1,0,42]);
 (%o84) [0,1,0]

unit_pulse(x, 'closed, 'closed) is a mess, but so it goes:

 (%i85) unit_pulse(x, 'closed, 'closed);
 (%o85) ((1-signum(x))*signum(x))/2-(signum(x-1)*(signum(x-1)+1))/2+1

 (%i86) unit_pulse(x, 'closed, 'open);
 (%o86) ((1-signum(x))*signum(x))/2-((1-signum(x-1))*signum(x-1))/2


A nonlocal simplification (that would be hard to do without uniformly
using signum for all these functions:

(%i93) is(equal(unit_step_right_continuous(x) - unit_step_left_continuous
(x), unit_blip(x)));
(%o93) true

Barton



_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima