floor, ceiling, and friends



Barton Willis wrote:

> -----Robert Dodier  wrote: -----
> 
> 
>>I propose that these be moved into maxima/src after testing.
> 
> 
> I think this would be ok -- the only tricky part of this code
> is the function that uses bfloat evaluation to find the floor
> and ceiling of constant expressions.  I encourage everybody
> to try to break this code.  Also, if you have better ideas or
> references, let me know. [My code is supposed to give up
> and return a noun form when it's too close to call.  For
> ill-conditioned expressions, it's possible the floor and
> ceiling could evaluate incorrectly.]
> 
I believe the commercial Macsyma has a sophisticated
program involved in this, courtesy of Bill Gosper, which allows the system
to decide how much precision is required to determine the
sign of (or,especially, the zeroness of ..) an expression.

Common lisp has some functions on purely numerical
inputs. I think that they are truncate, floor, ceiling, round.

Mod and Rem and so beclouded with alternate definitions that
I hesitate to use them.  (except on inputs that are positive
integers).

Regarding the use of mod for branch cuts, there is a small
literature on "winding numbers" which may be helpful.
I think there is a paper by Rob Corless in SIGSAM
Bulletin that should be online.


RJF

> 
>>There already exists a function compare in
>>src/compar.lisp which is somewhat similar. compare is never
>>called from anywhere in src/, test/, or share/, so far as I
>>can tell, and it is undocumented. So I think it is safe to cut the
>>existing compare and replace it with the nummod version.
> 
> 
> I agree.  I can not find any references to 'compare' either.
> The current 'compare' function is too confusing for
> me to use:
> 
> (%i3) compare(5,6);
> (%o3) NEG      <--- huh? what does this mean?
> 
> (%i4) load("C:/maxima/nummod/nummod.lisp")$
> (%i5) compare(5,6);
> (%o5) <
> 
> Yes, nummod and mod disagree for some negative inputs.
> My nummod function is suppose to follow the definition in
> "Concrete Mathematics," by  Graham, Knuth, and Patashnik.
> nummod is also supposed to mimic the behavior of Macsyma.
> I'm not sure mod and nummod should be merged -- I
> haven't looked into that.
> 
> Other:
> 
> (1) The nummod ode uses my version of compare.
> (2) In part, I wrote nummod to help fix branch cut
> bugs; for example
> 
>    carg(exp(%i * x)) --> x - nummod(%pi - x, 2 * %pi)
> 
> Barton
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima