In a fashion similar to Prob. 4.4, develop your own M-file to determine the smallest positive real

Question:

In a fashion similar to Prob. 4.4, develop your own M-file to determine the smallest positive real number used in MATLAB. Base your algorithm on the notion that your computer will be unable to reliably distinguish between zero and a quantity that is smaller than this number. Note that the result you obtain will differ from the value computed with realmin. Challenge question: Investigate the results by taking the base-2 logarithm of the number generated by your code and those obtained with realmin.


Data From Problem 4.4

For computers, the machine epsilon  can also be thought of as the smallest number that when added to one gives a number greater than 1. An algorithm based on this idea can be developed as

Step 1: Set ε = 1.
Step 2: If 1 + ε is less than or equal to 1, then go to Step 5. 

Otherwise go to Step 3.
Step 3: ε = ε / 2
Step 4: Return to Step 2
Step 5: ε = 2 × ε

Write your own M-file based on this algorithm to determine the machine epsilon. Validate the result by comparing it with the value computed with the built-in function eps.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: