Welcome to the First Laboratory Class
General GuidelinesIn 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.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?