Practical02 - COSC 1002/1902 Computational Science in C Practical 2 This practical session is concerned with floating point accuracy the use of

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COSC 1002/1902 Computational Science in C Practical 2 This practical session is concerned with floating point accuracy, the use of control structures in C, and with simple scientific problems involving solution of the quadratic equation. Before you begin these exercises, you should review the material in lecture 2. You should also download the codes in the lecture notes for lecture 2, rounding.c and quadratic.c , which are available via WebCT or from the website http://www.physics.usyd.edu.au/ ∼ wheat/cosc1002 . Compile and run the codes, following the steps outlined in the lecture notes, and confirm that you obtain the results described in the lecture notes. If you succeed with this then you are ready to begin the exercises. If not consult a tutor, who can provide assistance. The exercises are for students in both units except where indicated. Remember to get a tutor to mark off a checkpoint when you reach it. Exercises 1. As described in lecture 2, one situation where floating point rounding error can become impor- tant is when numbers with very different magnitude are added. For example, in an eight digit decimal floating point representation, 1 . 0000000 ⊕ 1 . 0000000 × 10- 8 = 1 . 0000000 . (1) Hence 10- 8 added to unity gives unity, in this representation. The machine accuracy (or machine epsilon ) is the smallest number that can be added to unity to give a number different from unity, for a given machine (computer). (a) Write a short code that prompts the user for a floating point number eps (this vari- able should have type float ), and then adds that number to 1.0 . In the code use an if-else statement to test whether the result is equal to...
View Full Document

This note was uploaded on 09/29/2009 for the course COSC 1002 taught by Professor Wheatland during the Three '09 term at University of Sydney.

Page1 / 5

Practical02 - COSC 1002/1902 Computational Science in C Practical 2 This practical session is concerned with floating point accuracy the use of

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online