[racket] Implementation of Simpson's Rule (SICP Exercise 1.29)

From: Konrad Hinsen (konrad.hinsen at fastmail.net)
Date: Thu Nov 7 10:29:43 EST 2013

Todd O'Bryan writes:

 > I just found a lovely Java expression to emphasize the inexactness of
 > doubles to my AP students. The problem--which I think is from
 > HtDP/1e--is to find the value of a bag of coins given the number of
 > pennies, nickels, dimes, and quarters. In BlueJ's code pad (or similar
 > in DrJava, jGrasp, etc.)
 > 
 > > 0.01 + 0.05 + 0.10 + 0.25
 > 0.410000000000000000003

That's a somewhat different problem: the impossibility of exact
conversion between base-10 and base-2 floats.

There isn't actually anything inexact about floating-point numbers,
what is (at least potentially) inexact is *operations* on
floating-point numbers. So the precise definition of Scheme's concept
of an inexact number is "a number that might be the result of an
inexact operation". What's particularly nasty in the example you show
is that the operation that causes the inexactness, base conversion, is
implicit.

Konrad.

Posted on the users mailing list.