On Sep 28, 2009, at 4:26 AM, Robert Dodier wrote:
> On 9/24/09, ?iga Lenar?i? <ziga.lenarcic at gmail.com> wrote:
>
> I'm not convinced. "if" in Maxima is truly a conditional expression
> (emphasis on "expression") for which typical expression operations
> are possible. In particular partial evaluation and simplification is
> applied to conditional expressions when the condition evaluates
> to something other than true or false. (Note that only atoms are
> evaluated; functions are not called.) It's very much in the same
> spirit as partial evaluation for arithmetic expressions: try to get
> as far as you can on what information is available.
>
> Incidentally, the current evaluation policy for "if" branches
> (evaluate atoms and simplify when test is not true and not false)
> was in place before I came on the scene.
>
> It is unfortunate that simplification can have a side effect
> (e.g. 1/0 and log(0) trigger errors) so e.g. if foo then 1/0 =>
> error when foo evaluates to itself. That's a wart in simplification,
> not a problem in conditional expressions.
>>
>
> best
>
> Robert Dodier
I think 'if' is used mainly for two very different things in Maxima:
1) programming concept
2) for defining piecewise functions ad hoc - f(x) := if x < 0 then x
else x^2;.
For the latter, simplifying 'then' and 'else' cases makes sense, but
it's not so good for the first one.
Furthermore 'if' is not a first class citizen in Maxima (compared to
Mathematica) - and this areas could be improved:
1) in Mathematica one can write diff( if x< 0 then x else x^2 , x)
and get the 'correct' result when 'if' is used for defining piecewise
functions
2) in Mathematica various commands return an 'if' statement if the
result is dependent on various parameters - so instead of asksign one
gets an 'if' expression (which is pretty neat and correct).
Also taking apart an 'if' statement with 'part' gives weird results -
so it's not a well behaved expression in that aspect also.
Perhaps 'if' could be strengthened in these areas to make it really a
first class mathematical expression?
Regards,
Ziga