[Maxima] Maxima interface to Lisp bit-functions
robert.dodier at gmail.com
Sat Mar 22 11:17:27 CDT 2008
On 3/19/08, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
> On Wed, Mar 19, 2008 at 5:39 PM, van Nek <van.nek at arcor.de> wrote:
> > bit_and(x) => x
> > bit_and(foo(y)) => foo(y)
> > bit_and(x, -x-1) => 0
> > Should these be valid for all x and foo,
> > or do they require that x is declared as integer and foo is declared as
> > integervalued?
> As a general rule, Maxima is extremely loose in typechecking. Not only
> does it simplify 0*x => 0, but even 0/x => 0 and "."(x) => x
Well, it's true that Maxima isn't always very careful, but I think
there is still something to gain by being more careful with
new operators (and old ones too, but that is more work).
So I would rather see simplifications of bitwise operators carried
out only if the argument is is known by Maxima to be an integer
(i.e. a literal integer or a symbol or function declared to be integral
or an expression which is demonstrably integral).
> > (%i1) declare(x,even);
> > (%o1) done
> > (%i2) featurep(x,even);
> > (%o2) true
> > (%i3) evenp(x);
> > (%o3) false
> This is confusing, I agree. evenp checks for even *literal numbers*:
> evenp(floor(x)*2) => false
> and featurep has been extended not only to look for features
> explicitly added to objects, but for the property in general:
> featurep(floor(x)*2,even) => true
featurep has evolved into a kind of a set membership test for a
few sets including integers, reals, complex numbers, and a few
others. I would like to see a general set membership test, e.g.
is(floor(x)*2 in even_integers), and make featurep just a
declaration test (as it once was, I believe). Of course set
membership is not a simple problem, but we may as well start
talking about what we would like to see.
More information about the Maxima