Sei sulla pagina 1di 2

MAL230: NUMERICAL METHODS AND COMPUTATION

(I-SEMESTER, 2014-2015)
LECTURER: HARISH KUMAR
TUTORIAL 1
See attached le matlab.zip in the mail. You have three le namely,
derivative_error.m, roundc.m and roundoff_errors_in_sampling.m. Download these les 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 nd the decimal equivalent of the following oating-point
binary machine number:
0 10000000011 1011100100010000000000000000000000000000000000000000
1 10000000101 1011100100000001000000000000000000000000000000000000
0 10000000001 1000101100010000000000000000000000000000000000000000
(b) Find the next largest and smallest machine numbers in decimal form for the number given in
1(a).
2. Consider a generic binary number
x = (1.d
1
d
2
d
t
d
t+1
)2
e
(a) What is the absolute and relative errors if f
1
(x) is chopped value of x after t digits.
(b) What is the absolute and relative errors if f
2
(x) is rounded value of x after t digits.
(c) Prove and discuss your results.
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) =
f(x + h) f(x)
h
.
One can easily see using Taylor expansion that f

can be approximated more accurately using,


f

(x) =
f(x + h) f(x 1)
2h
.
Modify derivative_error.m to implement this. Compare the result with the previous formula
and Justify your comments.
5. In general MATLAB uses 64-bit representation. Use Exercise 2 to nd out a upper bound
on the roundo error committed by this approximation.
6. Using roundc.m modify the computation in derivative_error.m so that all the oating point
operations are accurate upto 5 digits rounding o only. Compare the results with the one
without this round o. Plot the errors and Explain the behavior of the error curve.
1
2 (I-SEMESTER, 2014-2015) LECTURER: HARISH KUMAR TUTORIAL 1
7. Consider the evaluation of integral:
y
n
=

1
0
x
n
x + 10
dx.
(a) Prove that
y
0
= ln(11) ln(10), y
n
=
1
n
10y
n1
Use it to compute y
n
for n = 1, , 30. Note that in theory |y
n
| 1 n. Discuss and analyze
your results. Is this algorithms stable with respect to round o errors of MATLAB . If not
then explain.
Webpage: https://hkkaushik.wordpress.com/courses/mal230/
Lecturer: Harish Kumar (hkumar@maths.iitd.ac.in)
Tutorial Teacher: Asha
Date: 6th Aug, 2014
Exercises Due Date: No Submission Required.

Potrebbero piacerti anche