[Maxima] featurep(e, real)
robert.dodier at gmail.com
Tue May 16 09:58:06 CDT 2006
On 5/15/06, Stavros Macrakis <macrakis at gmail.com> wrote:
> What "nuttiness" did you have in mind?
Oh, I don't know. This looks pretty nutty to me.
(%i8) declare (X, complex);
(%i9) rectform (log (X));
Is X positive or negative?
> What do you suggest the value of featurep(sqrt(x),real)
> be in the absence of asksign?
> false -- because of course for x<0 it is imaginary
> x >= 0 -- a boolean expression
> true -- because we treat the domain of sqrt as real
featurep (x, real) and x >= 0 -- that's correct, isn't it?
Well, x in R and x >= 0 would be nicer ....
> The problem with the boolean expression is that most users
> of featurep would want to dispatch on the value, and aren't
> prepared to themselves return a conditional expression....
The right way to protect a function which doesn't cover
all the bases is to propagate a boolean or conditional
expression through it as a matter of course. There's no
guarantee that whichever case or branch Maxima chooses
is the one that's most interesting or useful to users,
and besides, it's incorrect.
That said, maybe aside from is / maybe / featurep we can have
demonstrable, which returns true iff Maxima knows how
to prove the proposition in question. A definition could be
demonstrable (x) := is (maybe (x) = true);
> If you need to catch the error, what is wrong with some
> error handling mechanism (preferably more sophisticated
> than errcatch...)?
How about evaluating the offending expression (say foo)
to undefined (foo) ? E.g. 1/0 => undefined (1/0) ,
signum (%i) => undefined (signum (%i)) . If the user must
see an explicit error message, it would be easy to set up
a global flag (ugh) which simplifies undefined to merror.
Of course, undefined (1/0) - undefined (1/0) is not 0; this
probably implies playing w/ gensyms and display properties
to ensure that undefined objects look the same externally
but different internally.
More information about the Maxima