Welcome to the First Laboratory Class
General GuidelinesThe 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.How to get started:Recommended Operating System: Linux
Recommended Programming Language: C
Recommended Editor: Emacs
Step 1. Login into the computer by providingStep 2. Open 1 X Term window (or any other window). Usually one should appear by default.Login:
Password:Step 3. Writing your program.
Type >emacs myprog.c &Step 4. Compiling and linking your program.This will open a file called myprog.c for editing. Type your program in this file.
Type >cc -o myprog myprog.cStep 5. Running your programType >./myprogProblems 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.0Do this for both single precision and double precision floating point numbers.
for k=1,2,3,...,100 dos <--- 0.5 send
t <--- s + 1.0
if t <= 1.0 thens <--- 2.0 sendif
output k-1, s
stopProblem 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?