Marc:
Here is a diff containing the following changes to _num.scm:
new macros: macro-exp-1/2, macro-exp--1/2, macro-log-2
new function: ##flonum.full-precision, which checks that (abs x) is
finite and above the largest subnormal number.
In ##log:
Define exact-log, which gives a finite answer for extremely large and
extremely small exact arguments, and better relative accuracy for
exact rationals near 1. It is slower than the old behavior of log on
exact rationals near 1, so if you just want a quick and dirty
approximation, use (log (exact->inexact x)).
Define complex-log-magnitude, which computes (log (magnitude x))
carefully in one step instead of in two steps.
in ##atan2:
Return exact 0 if x and y are exact, x is positive, and y is 0.
Carefully scale arguments before handling off to ##flonum.atan so more
answers are finite. Remove some checks, put them in calling functions.
in atan:
add checks before calling ##atan and ##atan2.
in ##sqrt:
Define complex-sqrt-magnitude, which carefully calculates (sqrt
(magnitude x)) in one step instead of two. For complex arguments,
return an exact result where possible, e.g., (##sqrt +2i) => 1+i.
I've included a test program below, and the results of that test
program in old-results and new-results. Many previous +nan.0 and +inf.
0 results are now finite; finite results that differ in more than the
last bit or so have more accuracy.
Brad