Created
July 9, 2012 18:37
-
-
Save dyoo/3078092 to your computer and use it in GitHub Desktop.
Epsilon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
;; http://en.wikipedia.org/wiki/Machine_epsilon | |
;; approximates the machine epsilon | |
(require racket/flonum) | |
(define (compute-machine-epsilon) | |
(let loop ([n 1.0]) | |
(define new-n (fl/ n 2.0)) | |
(cond | |
[(fl= 1.0 (fl+ 1.0 (fl/ new-n 2.0))) | |
new-n] | |
[else | |
(loop new-n)]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment