(II-SEMESTER, 2016-2017) Lecturer: Harish Kumar Tutorial 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

MTL509: NUMERICAL ANALYSIS

(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

4. Remember the discussion about the approximation of derivative of sin(x) in derivative_error.m


in class. We used the following formula to approximate derivative:
f (x + h) f (x)
f 0 (x) = .
h
One can easily see using Taylor expansion that f 0 can be approximated more accurately using,
f (x + h) f (x h)
f 0 (x) = .
2h
Modify derivative_error.m to implement this. Compare the result with the previous formula
and Justify your comments.

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.

7. Consider the evaluation of integral:


1
xn
Z
yn = dx.
0 x + 10
(a) Prove that
1
y0 = ln(11) ln(10), yn = 10yn1
n
Use it to compute yn for n = 1, , 30. Note that in theory |yn | 1 n. Discuss and analyze
your results. Is this algorithms stable with respect to round off errors of MATLAB . If not
then explain.
Webpage: https://hkkaushik.wordpress.com/courses/mtl509/
Lecturer: Harish Kumar ([email protected])
Date: 23rd Jan, 2017
Exercises Due Date: No Submission Required.

You might also like