815.worksheet03 - computer as rounding errors can build up...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Biostatistics 615/815 Problem Set 2 Due Wednesday, September 29 Floating Point Precision 1. This problem aims to explore the accuracy of floating point representations in your system. You should investigate the float and double data types in C as well as the default floating point representation in R. Write a program that calculates the following three quantities: a. The smallest positive number ε such that 1.0 + ε > 1.0. b. The smallest positive number ε * such that 1.0 – ε * < 1.0. c. The smallest positive number that can be stored in a variable and is > 0.0. 2. Care must be taken when evaluating certain mathematical expressions on a
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: computer, as rounding errors can build up to become quite large. One well known example relates to the golden ratio, φ . This number is: 61803398 . 2 1 5 = − = φ The number has the useful property that: (2) (1) 1 2 1 − − − − = = n n n n n Thus, successive powers of φ can be conveniently calculated using either expression (1) or (2). Starting with φ = 1 and φ 1 defined above, write an R program that fills an array with successive powers of φ using expression (1) and another array using expression (2). Plot both sets of results for φ n = 1. .80 . Which one appears more accurate? Why?...
View Full Document

This note was uploaded on 12/26/2011 for the course BIO 615 taught by Professor Abecasis during the Fall '10 term at University of Michigan.

Ask a homework question - tutors are online