Question: matlab a) The machine epsilon Em can also be thought of as the difference between 1 and the next higher number that can be stored
matlab 
a) The machine epsilon Em can also be thought of as the difference between 1 and the next higher number that can be stored using floating point representation on a computer. The matlab function eps () provides this value. Note that the distance between two floating point numbers is not constant. The following function computes the value of the epsilon function eplison = ep (n) eplison = double (1); r = eplison/2; while (n+eplison) eplison = eplison/2; r = eplison/2; end eplison= eplison*2; end = n Use the above function to compute the value of e for different values of n. Use n= 1,2,3,4,5, 7, 8, 15, 200, 1022, and 1023, 1.3e6. Explain the results you obtain. b) The function provided in part a gives an estimate of the absolute roundoff error when storing a Real number as a floating-point number n (the round-off error is e/2). Write a similar function rel_ep (n) that computes the relative error. Call the function for the same values of n used in part a. Explain the difference in the results. c) Using your knowledge of the floating-point representation find and evaluate an expression that computes epsilon at 1 for a single precision (32bit) floating point number (compare with the matlab function eps ( 'single'). a) The machine epsilon Em can also be thought of as the difference between 1 and the next higher number that can be stored using floating point representation on a computer. The matlab function eps () provides this value. Note that the distance between two floating point numbers is not constant. The following function computes the value of the epsilon function eplison = ep (n) eplison = double (1); r = eplison/2; while (n+eplison) eplison = eplison/2; r = eplison/2; end eplison= eplison*2; end = n Use the above function to compute the value of e for different values of n. Use n= 1,2,3,4,5, 7, 8, 15, 200, 1022, and 1023, 1.3e6. Explain the results you obtain. b) The function provided in part a gives an estimate of the absolute roundoff error when storing a Real number as a floating-point number n (the round-off error is e/2). Write a similar function rel_ep (n) that computes the relative error. Call the function for the same values of n used in part a. Explain the difference in the results. c) Using your knowledge of the floating-point representation find and evaluate an expression that computes epsilon at 1 for a single precision (32bit) floating point number (compare with the matlab function eps ( 'single')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
