0% found this document useful (0 votes)
60 views2 pages

Computational Physics Lab Test 2011: 1 The Problem

The document summarizes an experiment to determine the smallest positive number that can be represented on a computer using single and double precision floating point numbers. It includes encoding an algorithm to iteratively divide a starting number by 2 and add 1, outputting the iteration when this sum is no longer less than 1. Running the algorithm on the author's computer, it was found that the 52nd iteration was the epsilon for double precision, 2.220446e-16, and the 23rd iteration was the epsilon for single precision, 1.192093e-07. The document concludes that double precision numbers have more precision than single precision as its epsilon is smaller.

Uploaded by

prahalad19
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views2 pages

Computational Physics Lab Test 2011: 1 The Problem

The document summarizes an experiment to determine the smallest positive number that can be represented on a computer using single and double precision floating point numbers. It includes encoding an algorithm to iteratively divide a starting number by 2 and add 1, outputting the iteration when this sum is no longer less than 1. Running the algorithm on the author's computer, it was found that the 52nd iteration was the epsilon for double precision, 2.220446e-16, and the 23rd iteration was the epsilon for single precision, 1.192093e-07. The document concludes that double precision numbers have more precision than single precision as its epsilon is smaller.

Uploaded by

prahalad19
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Computational Physics Lab Test 2011

Sayan Chatterjee 11PH40043 January 25, 2012

The Problem

Problem 1: Encode the following algorithm and run it to determine the smallest positive number that can be represented on the computer you are using: input s <--- 1.0 for k=1,2,3,...,100 do s <--- 0.5 s t <--- s + 1.0 if t <= 1.0 then s <--- 2.0 s output k-1, s stop endif end Do this for both single precision and double precision oating point numbers.

2
2.1

Method
The program

#include<stdio.h> main() { double s=1.0,t=0.0; int k;

} }

For Float we dene float s=1.0;

2.2

Inputs and Outputs from Linux Terminal

For Double : 52 th term is Computer Epsilon 2.220446e-16 For Float: 23 th term is Computer Epsilon 1.192093e-07

Results

We get the Computer Epsilon for the specic computer on which it is run.

Discussions and Conclusions

Computer epsilons for oat and double are dierent.Double has more precision and the epsilon for double is hence smaller.Any value beyond computer epsilon is insignicant to us and bears no meaning. OS: Fedora 16 Text Editor : vi,gedit Prepared using : TEX

You might also like