MATH 4329 Homework 2 Fall 2014 Due: 9:00 a.m. on Wednesday, Sept. 17, 2014 Note: Show all important steps to solve a given problem to receive full credits. If you are asked to write a MATLAB program, please provide your code, output as well as explanations of your results (Also, email your code to your TA at [email protected]). You may adopt and modify the sample codes in the text book. (15 pts) 1. Take the last two digits of your UTEP ID number(80 number) and call it m (for example, m=78). (a) Find the binary floating-point representation and machine representation in IEEE double precision format for m by hand. (b) Using MATLAB command format hex, confirm your answer in (a). (Hint: see the example of (2.6)–(2.7) on page 37. ) (c) To generate overflow and underflow errors on your computer, write a MATLAB program to evaluate mn and m1n for n = 1, 2, 3, 4, · · · . Eventually, you will exceed your machine’s exponent limit for floating-point numbers. For what n do you get overflow error and underflow errors? Note: write your program in such a way that it prints only the number n that gives you overflow and underflow errors. Do not print all the intermediate values mn or m1n . (15 pts) 2. A certain microcomputer uses a binary floating-point format with 4 bits for the exponent e and 1 bit for the sign σ. The normalized mantissa x̄ contains 4 bits. The arithmetic uses rounding. (a) Find the machine epsilon, i.e., the distance between 1 and the next larger floatingpoint number. (b) Let x = (7.125)10 . Find its floating-point approximation fl(x). Give fl(x) in decimal. (c) What is the relative error in fl(x) (20 pts) 3. In some cases, loss-of-significance errors can be avoided by reformulating functions to avoid the subtraction of nearly equal quantities. Consider the following functions: √ 4+x−2 x − sin x f (x) = , g(x) = x x3 For each function, f (x) and g(x), 1 x 10−1 .. . f(x) (or g(x)) 10−15 (a) Use Calculus to find the limit as x → 0. (b) Write a MATLAB program to evaluate the function as it is written at x = 10−n , n = 1, 2, · · · , 15. Print the results in the above tabular format and describe your observation. (c) Reformulate the function to eliminate loss-of-significance errors and evaluate it at x = 10−n , n = 1, 2, · · · , 15. Print the results in the same format as (b) 2
© Copyright 2026 Paperzz