(II-SEMESTER, 2016-2017) Lecturer: Harish Kumar Tutorial 1
(II-SEMESTER, 2016-2017) Lecturer: Harish Kumar Tutorial 1
(II-SEMESTER, 2016-2017)
LECTURER: HARISH KUMAR
TUTORIAL 1
See attached file matlab.zip in the mail. You have two files namely, derivative_error.m,
roundc.m. Download these files and go through them. We have already discussed them in class.
They will be useful in the following exercises.
1. (a) Use the 64-bit long real format to find the decimal equivalent of the following floating-point
binary machine number:
0 10000000011 1011100100010000000000000000000000000000000000000000
1 10000000101 1011100100000001000000000000000000000000000000000000
0 10000000001 1000101100010000000000000000000000000000000000000000
(b) Find the smallest greater and largest smaller numbers in decimal form for the number
given in 1(a).
2. Consider real number
x = (d0 .d1 d2 dt1 dt ) e
which is approximated by a finite t-digit number using chopping:
f l(x) = (d0 .d1 d2 dt1 ) e
and rounding:
(
(d0 .d1 d2 dt1 ) e if dt < /2
f l(x) =
(d0 .d1 d2 dt1 + 1t ) e if dt /2.
Show that absolute errors are
(
1t e , for chopping
1 1t e
2
, for rounding
and relative errors are, (
1t , for chopping
1 1t
2
, for rounding.
3. Write a MATLAB program that takes input a number x (or array of numbers) and a param-
eter n. Output is chopped value (or array) of x up to n digits.
Hint: Modify roundc.m
1
2 (II-SEMESTER, 2016-2017) LECTURER: HARISH KUMAR TUTORIAL 1
5. In general MATLAB uses 64-bit representation. Use Exercise 2 to find out a upper bound
on the roundoff relative error committed by this approximation.
6. Using roundc.m modify the computation in derivative_error.m so that all the floating point
operations are accurate upto 5 digits rounding off only. Compare the results with the one
without this round off. Plot the errors and Explain the behavior of the error curve.