present state of unevaluated conditionals, was: Handling branch cuts ...
Subject: present state of unevaluated conditionals, was: Handling branch cuts ...
From: Robert Dodier
Date: Sat, 12 Feb 2005 15:00:31 -0800 (PST)
Hello,
On further consideration, it looks like unevaluated conditionals
as they stand might be able to handle the case in question.
I would really recommend that we consider this scheme.
Maxima already has unevaluated conditionals, it's just that
most functions (diff, integrate, etc) know nothing about them
so they aren't very useful. This is spelled out in a message
dated 2004/10/22 by Stavros to the mailing list.
(http://www.ma.utexas.edu/pipermail/maxima/2004/008419.html)
But Maxima knows enough about unevaluated conditionals to
make them useful in this context. Consider:
(%i1) AS1(x) := x^3$
(%i2) AS2(x) := %pi - x$
(%i3) declare (x, complex);
(%o3) done
(%i4) expr: 'if realpart(x) < 1 then 'AS1(x) else
'if equal(imagpart(x),0) then 'AS2(x) else 'FOO;
(%o4) mcond(realpart(x) < 1, AS1(x), true,
mcond(equal(imagpart(x), 0), AS2(x), true, FOO))
(%i5) assume (realpart(x) < 1)$
(%i6) expr, nouns;
3
(%o6) x
(%i7) forget (realpart(x) < 1)$
(%i8) assume (realpart(x) > %pi)$
(%i9) assume (equal (imagpart (x), 0))$
(%i10) expr, nouns;
(%o10) %pi - x
(%i11) forget (equal (imagpart (x), 0))$
(%i12) assume (not (equal (imagpart (x), 0)))$
(%i13) expr, nouns;
(%o13) FOO
If some function returns an unevaluated conditional,
Maxima is at least smart enough to evaluate the alternatives
when information becomes available to choose among them.
Returning an unevaluated conditional seems to be the
appropriate result, mathematically. The question is whether
Maxima has enough support to make the construct useful.
I believe that is the case.
Incidentally the strange representation "mcond (...)"
appears to be a bug (an overlooked case) in the display code.
An expression with %MCOND as the operator displays as
mcond (...) while an expression with MCOND displays
as if ... then ... .
For what it's worth,
Robert Dodier
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail