if then and unit_step



All that is true, but not terribly useful, since Maxima does very few simplifications on unit_step, not even unit_step(x)*unit_step(-x) => 0. 
Sometimes ratsimp() can simplify some cases, pw.mac can do some cases.  I don?t think its useless.

Rich
 
            -s


On Fri, Oct 7, 2011 at 13:26, Richard Hennessy <rich.hennessy at verizon.net> wrote:

  It has occurred to me on various occasions, that you can do logic in Maxima by using step functions.  The unit_step() function, which is used in pw for representing piecewise functions, is bi-valued. So are Boolean expressions. You can represent connectors like "and", "or" and "not" as expressions involving unit_step().

  Consider if x>a and x>b then u else v;

  It is equivalent to the following, if you agree with the idea that how an expression evaluates is all that matters.

  (u - v) * unit_step(x - max(a, b)) + v;

  then there is "or" as in the following

  if x>a or x>b then u else v;

  It is equivalent to the following.

  (u - v) * unit_step(x - min(a, b)) + v;

  Another possibility is

  if (x > a) and (x < b) then u else v

  (v - u) * unit_step(x - b) + (u - v) * unit_step(x - a) + v

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