Maxima interface to Lisp bit-functions



Dear Mr Fateman,

what you read in the subject line, had already been defined. Just by accident, I was looking 
for simplication functions for logarithms, I found that there are the functions

logand
logor
logxor

in share/simplification/functs.mac
They are just nothing but ?boole(...)
and they are defined wrong!

What should we do here? Fix them or cut them out?

Volker van Nek
 

Am 21 Mar 2008 um 14:04 hat Richard Fateman geschrieben:

> 
> I haven't chimed in here, but I suspect that the subject is not
> right.
> 
> access to lisp is available via ?lispfunction.
> If you are defining new functions that operate on Maxima data like
> %pi and x, then you are not 
> interfacing to lisp functions. You are defining analogs to lisp
> functions that can be used in 
> Maxima, suitably extended for the cases that lisp would give errors
> on.
> 
> I don't really have a problem with that latter task, just the
> subject line :)
> rjf
> 
> 
> 
>     From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] 
>     On Behalf Of van Nek
>     Sent: Friday, March 21, 2008 1:59 PM
>     To: Stavros Macrakis
>     Cc: Maxima at math.utexas.edu
>     Subject: Re: [Maxima] Maxima interface to Lisp bit-functions
> 
> 
> 
>     > > 2. bitwise test for bit value 1
>     > > bit_onep(8,3) => true
>     > 
>     > I think I'd prefer to define bit_onep(x,i) so that for integer
> x it
>     > is
>     > the same as bit_and(x,2^i)=1. This gives bit_onep(8,2) =>
> true.
> 
>     Mmmh? 8=2^3. I can't follow here.
> 
> 
>     > Bit_onep extends naturally to all real numbers:
> bit_onep(0.5,-1)
>     > =>
>     > true; bit_onep(%pi,-1)=>false, etc.
> 
>     I know you are in favour of extending these functions. But today
> I regard these extensions 
>     as future plans.
> 
> 
>     > Some more simplifications
>     > bit_onep(oddnum,0) => true; evennum,0 => false
>     > bit_onep(k^n,m) => true if (NOT iff) m=n*log(k)/log(2)
>     > bit_onep(x,n) where 0<=x<2^n => false
> 
>     Thank you for this. I will try to code it.
> 
> 
>     > > 3. bitlength
>     > > bit_length(8) => 4
>     > OK, == floor(log(x)/log(2)) for x>0, right?
> 
>     No, 8=1000
>     and floor(log(8)/log(2)) = 3
> 
>     I think
>     bit_length(x)== floor(log(x)/log(2)) + 1 for x>0
> 
>     By the way, there is a floor bug:
>     (%i1) floor(log(8)/log(2));
>     (%o1) 2
>     (%i2) float(log(8)/log(2));
>     (%o2) 3.0
> 
> 
>     > Additional simplification
>     > bit_length(2^n) => n (n>=0) (also 4^n=>2*n, etc.)
> 
>     Thank you for this. I will try to code it.
>     But again, I think it's
>     bit_length(2^n) => n +1 (n>=0) (also 4^n=>2*n+1, etc.)
> 
>     Volker