Welcome to the First Laboratory Class

General Guidelines
In the laboratory class we shall be discussing the problems, how to solve them and finally we shall be looking at the results when you have solved the problem. You wil be expected to write the programs at your own leisure and present the results on the submission date.

Recommended Operating System: Linux

Recommended Programming Language: C

Recommended Editor: Emacs
 

How to get started:
Step 1. Login into the computer by providing
Login:
Password:
Step 2. Open 1 X Term window (or any other window). Usually one should appear by default.

Step 3. Writing your program.

Type >emacs myprog.c &

This will open a file called myprog.c for editing.  Type your program in this file.
 

Step 4. Compiling and linking your program.
Type >cc -o myprog myprog.c
Step 5. Running your program
Type >myprog
Problems to be solved:

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 floating point numbers.

Problem 2: Evaluate the expression y=(x^2 + 1.0)^(0.5)-1.0 in two ways

(a.) y <-  (x^2 + 1.0)^(0.5)-1.0

(b.) y <-    x^2/[(x^2+1.0)^(0.5)+1.0]

    for small values of x, x=0.1, 0.01 and 0.001, Determine the fractional error in both the methods of performing the subtraction.
 
    Which metthod is superior, abd why?