[racket-dev] Sublinear functions of superfloat numbers
Perfectly good summary, my good man.
Anyway, I've decided to regard `log' (with huge rationals) and `sqrt'
(with perfect squares) as anomalies, because I'm finding more examples
that don't work. Here's one:
> (real->double-flonum (/ #e1e400 #e1e200))
1e+200
> (/ #e1e400 1e200)
+inf.0
So it appears that the rules for irrational functions are:
1. Return an exact answer for a few exact values (e.g. (sqrt <perfect
square>) = <integer>)
2. (optional; no rules or guidelines) Reduce arguments to flonum range
3. Convert to flonum and compute
It's actually a bit of a relief that I don't have to worry about this.
Neil ⊥
On 07/02/2012 03:11 AM, Jens Axel Søgaard wrote:
> Is the following a fair summary?
>
> The idea is to divide the real axis in three parts.
> x < y < z
>
> Here x is a real (double), y is a slightly larger than +max.0,
> and z is a very large.
>
> Now sqrt(x) is just a real (double).
>
> Let y be an exact integer only slightly larger than +max.0.
> Even though y is larger than +max.0 the true sqrt of y is
> actually smaller than +max.0 and thus representable as a float.
> It is therefore possible to extend the standard sqrt function
> to numbers slightly above +max.0.
>
> For very large numbers z where sqrt(x) is larger than +max.0
> return +inf.0 unless z happens to be a perfect square.
>
>
> The sqrt function is a sublinear function. This extension is also
> possible for other members of this class such as the logarithms.
> How to extend the function depend on the function.
>
>
> The other example, the periodic trigonometric functions is
> slighly different.
>
> Here the problem is that the argument must be reduced before
> the actual computation can take place. The reduction is
> simple in principle - just subtract the period repeatedly
> until the argumet is so small the standard function works
>
> However the period irrational, so in order to avoid loss of
> precision, one must compute the period with an appropriate
> number of decimals compared to the argument before the
> reduction can take place.
>
> /Jens Axel
>