On 10/7/2011 10:26 AM, Richard Hennessy 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().
In maxima, "if"s can result in evaluating the "then" clause, the "else"
clause, an error (prederror), or an unevaluated expression.
>
> Consider if x>a and x>b then u else v;
>
> It is equivalent to the following,
.... not really...
> if you agree with the idea that how an expression evaluates is all
> that matters.
I'm not sure what you mean by this.
>
>
> (u - v) * unit_step(x - max(a, b)) + v;
no, can't do that since it evaluates both u and v.
If it cannot be determined if " x>a and x>b" or not, then NEITHER u
nor v is evaluated.
I haven't looked at the rest of the stuff in detail, and it certainly
could be both correct and useful in some context.
Just that I'm pretty sure you can't automatically convert arbitrary
maxima-version if's to it.
Also I suspect evaluating conjunctions etc by "short circuiting" would
cause results to differ.
RJF