Welcome to the First Laboratory Class

General Guidelines
The laboratory class  shall focus on how to solve physics problems using computers. The problems will be put up on this web-site and you are expected to write programs inC language and solve these problems. Those who are not familiar with computer programming are expected to it pick up through their own effort as the course proceeds. The 3 hr lab class shall be mainly devoted to discussing  the problems and addressing specific difficulties faced by the students. You are encouraged to ask questions and clear  all doubts  during the lab class. Further,  you are 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?