couple of questions on scheme arithmetic
Author 
Message 
John Perk #1 / 17

couple of questions on scheme arithmetic
r5rs reccommends use of IEEE floatingpoint if you're going to use floatigpoint at all. This leaves me with a couple of questions regarding infinities and NaN values. If NaN values are permitted, so (define NaN (/ #i0 #i0)) is allowed, then we would have (= NaN NaN) returning #f (if we allow arithmetic on NaN's; we could insist that NaN fails the number? predicate, but then what type would they be?) which leads to the same result when testing with eqv? and eq? and we have an object being not eq? to itself. I don't think this is forbidden by the standard, but I'd like to be sure because it does seem odd. On infinities, should their be only one exact infinite value, as on the Riemann sphere (so the IEEE positive and negative infinity values would have to return #t when tested by (=)? At the other end of the spectrum, although traditionally (angle 0) is undefined, is it acceptable for an inexact zero to have a defined theta value (meaning "a number of magnitude too small to denote but with a known angle from the real line")? Finally, does inexactness of number always have to be proagated? For intance (imagpart #i1) returns an inexact zero, when the realness of the number is in no doubt (unlike #i1+0i). There seems to be so way to express a complex literal with one part exact and the other not; in spite of this, should an exact part of a complex number be recoverable exactly? e.g. (realpart (makerectangular #e1 #i1)) Thank you

Sat, 06 Jul 2002 03:00:00 GMT 


Barry Margoli #2 / 17

couple of questions on scheme arithmetic
Quote: >r5rs reccommends use of IEEE floatingpoint if you're going to use >floatigpoint at all. This leaves me with a couple of questions regarding >infinities and NaN values. >If NaN values are permitted, so >(define NaN (/ #i0 #i0)) >is allowed, then we would have (= NaN NaN) returning #f (if we allow >arithmetic on NaN's; we could insist that NaN fails the number? predicate, >but then what type would they be?) which leads to the same result when >testing with eqv? and eq? and we have an object being not eq? to itself. I >don't think this is forbidden by the standard, but I'd like to be sure >because it does seem odd.
I think you're right, although I suspect that some implementations would get this wrong. Either they'll return #t for both eqv? and eq? (violating the specification of eqv?, which says that it returns what = would return for numbers) or eqv? will return #f and eq? will return #t (violating the requirement that eq? of numbers only return #t when eqv? would return #t). Except for these special IEEE values, the equivalence predicates form a hierarchy  if a more discriminating predicate considers objects equivalence, so will all the less discriminating ones, and eq? is the most discriminating. eq? is generall implemented by comparing pointers for boxed types, so an object would always be eq? to itself, and it may be common to perform this quick pointer test in the other equivalence functions before dispatching on the type. 
GTE Internetworking, Powered by BBN, Burlington, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me  I'll assume it wasn't posted to the group.

Sun, 07 Jul 2002 03:00:00 GMT 


Bradley J Luci #3 / 17

couple of questions on scheme arithmetic
At a Scheme workshop at ICFP '98 in Baltimore I made a proposal to modify Scheme semantics a bit to accomodate IEEE arithmetic. I believe it was Will Clinger's opinion that the only thing that needed to be changed in the standard was the definition of eqv?; I suggested that two IEEE floatingpoint numbers be eqv? iff they had the same signs, exponent widths, biased exponents, fraction widths, and fraction values (basically, the same bit patterns, phrased in terms used in the IEEE 754 standard in order to ignore problems of field placement, etc.). I believe that, together with other relevant changes, this has been implemented by the PLT group at Rice in MzScheme; Marc Feeley has adopted this for the next release of GambitC; and I believe that Kent Dybvig intended to implement the same in Chez Scheme. Brad Lucier

Sun, 07 Jul 2002 03:00:00 GMT 


David Rus #4 / 17

couple of questions on scheme arithmetic
Quote:
> r5rs reccommends use of IEEE floatingpoint if you're going to use > floatigpoint at all. This leaves me with a couple of questions regarding > infinities and NaN values. > If NaN values are permitted, so > (define NaN (/ #i0 #i0)) > is allowed, then we would have (= NaN NaN) returning #f (if we allow > arithmetic on NaN's; we could insist that NaN fails the number? predicate, > but then what type would they be?) which leads to the same result when > testing with eqv? and eq? and we have an object being not eq? to itself. I > don't think this is forbidden by the standard, but I'd like to be sure > because it does seem odd.
I think the problem is still deeper. IIRC, there are many differrent NaN representations, each with possibly different meanings (although I think that is implementationspecific). As you have defined NaN, I would expect it to be eq?, eqv?, equal?, and possibly = to itself (in Guile it is eq? eqv? and equal?, but not =). However, if (define logNaN (log 0)) I would thoroughly expect logNaN to not be eq? etc to NaN. I guess that I think that Guile has it mostly right (it does (number? NaN) => #t, which is maybe not right), but if the standard prohibits eq? then I think the standard has a problem. I just can't see how it can be a good thing to be able to compute a value from which you can extract *no* information, including its own existence. Which brings me to the reason I posted. Does anyone else think that it makes sense to have a readsyntax for the value returned from (if #f #f), aka the unspecified value. I find it to be a useful for lazyinitializations, in particular, because #f actually means something. I'm essentially looking for a 'bottom' value in the Scheme lattice. NaNs perform some of the same function in the numerical tower... david rush  From the start...the flute has been associated with pure (some might say impure) energy. Its sound releases something naturally untamed, as if a squirrel were let loose in a church." Seamus Heaney

Mon, 08 Jul 2002 03:00:00 GMT 


Robin Poppleston #5 / 17

couple of questions on scheme arithmetic
Quote:
> r5rs reccommends use of IEEE floatingpoint if you're going to use > floatigpoint at all. This leaves me with a couple of questions regarding > infinities and NaN values. > If NaN values are permitted, so > (define NaN (/ #i0 #i0)) > is allowed, then we would have (= NaN NaN) returning #f (if we allow > arithmetic on NaN's; we could insist that NaN fails the number? predicate, > but then what type would they be?) which leads to the same result when > testing with eqv? and eq? and we have an object being not eq? to itself. I > don't think this is forbidden by the standard, but I'd like to be sure > because it does seem odd.
Mathematicians have been over this ground a long time ago. (1) The Natural numbers (which are not even a distinguished type in Scheme, though I believe they are in Haskell) can be embedded in two different constructs that provide an account of the infinite, namely the cardinals and the ordinals. The infinite cardinals are distinct (for example the cardinality of a countable set is distinct from the cardinality of the continuum by Cantor's diagonal argument). In fact, there are infinitely many of them. Likewise the infinite ordinals are distinct, but there are more of them. (2) The usual pure mathematician's account of the reals does not allow anything like an infinity or an indeterminate value. Essentially, the algebra of the reals gets full of exceptions if you try to include infinities. Without infinities the reals are a field, which is a nice, well understood, kind of algebra. Much of the clever factorisation stuff that's done with computer algebra depends on Field Theory. (3) But of course applied mathematicians have been peddling thingies with infinite values like the Dirac delta function. I don't know if anybody has given an account of that beast (which is an infinite spike with a finite integral). However the NaN value doesn't fill the bill for this one. Scheme is one of the few languages with a nearperfect representation of the integers and of the rationals. It might be as well to preserve that tradition of mathematical literacy. Division by zero is not a legal operation in a field. Allowing it violates the algebraic laws on which any proof of the correctness of a program depends. How you indicate that it's happened is an important issue, but it's one to do with how you handle exceptions  the question being how you purvey a mathematical error to your enduser. And finally the issue of a bottom value. If I understand the theorists rightly, bottom is in fact a noncomputable notion. If you interpret lambda expressions as denoting partial functions, then bottom denotes that partial function which maps no values. So you must solve the halting problem to determine whether a particular expression evaluates to bottom. There is another possible lattice we might consider in Scheme, namely the typelattice, which we may regard as a lattice whose members are certain "describable" subsets of Scheme objects. The natural bottom of this lattice is the empty set, which contains no objects. We might consider having an element "bottom", which lies immediately above the empty set in our typelattice, thereby requiring that all types contain this bottom element as a member. If we do that, then the type of rationals must contain it: consequently Scheme rationals cease to be an accurate representation of what mathematicians understand as the rationals, and one of the glories of Scheme goes down in flames. Robin.

Tue, 09 Jul 2002 03:00:00 GMT 


George Russel #6 / 17

couple of questions on scheme arithmetic
Quote:
> r5rs reccommends use of IEEE floatingpoint if you're going to use > floatigpoint at all. This leaves me with a couple of questions regarding > infinities and NaN values.
So you want to know about IEEE floatingpoint do you? Go to William Kahan's home page: http://HTTP.CS.Berkeley.EDU/~wkahan/ especially the subsection http://www.cs.berkeley.edu/~wkahan/ieee754status/

Tue, 09 Jul 2002 03:00:00 GMT 


John Atwo #7 / 17

couple of questions on scheme arithmetic
Quote: >So you want to know about IEEE floatingpoint do you? Go to >William Kahan's home page: > http://HTTP.CS.Berkeley.EDU/~wkahan/ >especially the subsection > http://www.cs.berkeley.edu/~wkahan/ieee754status/
Thank you for that URL; I learned more about IEEE754 in an hour there than I did in 2 classes on computer architecture, such as: some of the achievements, shortcomings, and outstanding problems with the standard some real world issues, such as claimed conformance achievable only with substantial performance penalties, why a Mac is better than a Cray wrt IEEE754 how/why some languages (Java, Haskell, C, C++) fail to support the standard how some compilers mess with the standard (Microsoft and the exception flags) some of the history of the standard (including some of the politicial maneuverings). I think I'm beginning to understand what Simon Thompson means when he writes of Haskell's builtin types: In the case of floatingpoint and complex numbers, it seems highly unlikely that any satisfactory (but sound!) axiomatisation exists, and we would argue that this part of the language be omitted from the logic. [1] I certainly appreciate why Kahan won the Turing Award. Many Thanks, John Atwood  [1] Formulating Haskell. Simon Thompson. Technical Report 2992*, University of Kent, Computing Laboratory, University of Kent, Canterbury, UK, November 1992.

Tue, 09 Jul 2002 03:00:00 GMT 


Davi #8 / 17

couple of questions on scheme arithmetic
Quote: >I certainly appreciate why Kahan won the Turing Award.
Kahan certainly is a genius but he's not someone you'd want to work with. The entire CS department at Berkeley makes exceptions for people taking his class because he likes to set negative scores for midterm means and he doesn't curve. The guy is quite a character. =) Admire his brain, but don't admire him too much =P

Tue, 09 Jul 2002 03:00:00 GMT 


Per Bothne #9 / 17

couple of questions on scheme arithmetic
Quote: > I suggested that two IEEE floatingpoint numbers be eqv? iff > they had the same signs, exponent widths, biased exponents, fraction > widths, and fraction values (basically, the same bit patterns, > phrased in terms used in the IEEE 754 standard in order to ignore > problems of field placement, etc.). > I believe that, together with other relevant changes, > this has been implemented by the PLT group at > Rice in MzScheme; Marc Feeley has adopted this for the next > release of GambitC; and I believe that Kent Dybvig intended > to implement the same in Chez Scheme.
This is also how Kawa works, assuming I understand you correctly: (eqv? nan nan) is #t and (= nan nan) is #f.  Per Bothner

Tue, 09 Jul 2002 03:00:00 GMT 


Joseph Dal #10 / 17

couple of questions on scheme arithmetic
Quote:
> >I certainly appreciate why Kahan won the Turing Award. > Kahan certainly is a genius but he's not someone you'd want to work > with. The entire CS department at Berkeley makes exceptions for > people taking his class because he likes to set negative scores for > midterm means and he doesn't curve. The guy is quite a character. =) > Admire his brain, but don't admire him too much =P
I have taken a class from Kahan as well, perhaps the same one I think you are referring to. Whatever you may think of him, this is not the place to be taking shots at his teaching style  it's not at all relevant to this discussion, and it's very impolite, especially if you choose to hide behind your anonymity. However unlikely it may seem, Kahan could easily be reading our words. If you have something bad to say about him, have the sense not to say it to his face, or even in public. Please keep such comments to yourself. If you are bitter about your experience with him, we don't need to know.

Wed, 10 Jul 2002 03:00:00 GMT 


Chris Saunder #11 / 17

couple of questions on scheme arithmetic
Quote:
> > >I certainly appreciate why Kahan won the Turing Award. > > Kahan certainly is a genius but he's not someone you'd want to work > > with. The entire CS department at Berkeley makes exceptions for > > people taking his class because he likes to set negative scores for > > midterm means and he doesn't curve. The guy is quite a character. =) > > Admire his brain, but don't admire him too much =P > I have taken a class from Kahan as well, perhaps the same one I think > you are referring to. Whatever you may think of him, this is not the > place to be taking shots at his teaching style  it's not at all > relevant to this discussion, and it's very impolite, especially if you > choose to hide behind your anonymity. However unlikely it may seem, > Kahan could easily be reading our words. If you have something bad to > say about him, have the sense not to say it to his face, or even in > public. Please keep such comments to yourself. If you are bitter about > your experience with him, we don't need to know.
I don't know  I "busted a gut" reading that one and of course couldn't take it too seriously. I don't know this Kahan personally but he might have a good yelp at it too. Regards Chris Saunders

Wed, 10 Jul 2002 03:00:00 GMT 


Page 1 of 2

[ 17 post ] 

Go to page:
[1]
[2] 
