[Scheme-reports] Mixed exactness in complex numbers? Peter Bex (23 Mar 2012 19:13 UTC)
Re: [Scheme-reports] Mixed exactness in complex numbers? Andrew Robbins (23 Mar 2012 19:48 UTC)

Re: [Scheme-reports] Mixed exactness in complex numbers? Andrew Robbins 23 Mar 2012 19:48 UTC

Peter,

I hope this isn't considered too off-topic, but Mathematica has 4
distinct infinities.
The usual Infinity (+inf.0 in Scheme), -Infinity (-inf.0 in Scheme),
and the following:

- ComplexInfinity (might be represented in Scheme as (make-polar
+inf.0 +nan.0)), and
- DirectedInfinity[z] (might be represented in Scheme as (make-polar
+inf.0 (angle z))).

If we restrict our domain to inexact floating point real numbers,
these two infinities still represent something meaningful, and cannot
be converted to inexact rectangular complex numbers without losing
information. To make this less about polar complex numbers, consider
the logarithm of a directed infinity. (log (make-polar +inf.0 y))
should be +inf.0+yi, whatever y is. If y is an exact number, then
(imag-part (log ...)) should also be exact. I'm not sure how many
Scheme implementations actually store exact polar complex numbers this
way, but it helps keep numbers exact.

Regards,
Andrew Robbins

On Fri, Mar 23, 2012 at 3:13 PM, Peter Bex <Peter.Bex@xs4all.nl> wrote:
> Hi all,
>
> The report occasionally mentions "an inexact complex number" or
> "an exact complex number".  Does this imply that there's no such
> thing as a complex number of mixed exactness?
>
> Gambit, for example, allows this: 1/2+0.5i
> Other Schemes I've looked at (not that many, though) return a
> normalised complex number with both real and imaginary parts
> converted to inexact.
>
> As far as I can see, this only has impact on the behavior of
> eqv?, which needs to check that the exactness of both parts
> match and then compare both parts with the regular "=" procedure.
> I'm not sure about the usefulness of this (but I'm not convinced
> it's useless, either)
>
> Am I missing anything?
>
> Cheers,
> Peter
> --
> http://sjamaan.ath.cx
> --
> "The process of preparing programs for a digital computer
>  is especially attractive, not only because it can be economically
>  and scientifically rewarding, but also because it can be an aesthetic
>  experience much like composing poetry or music."
>                                                        -- Donald Knuth
>
> _______________________________________________
> Scheme-reports mailing list
> Scheme-reports@scheme-reports.org
> http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports