遇到一道题目:"for computers, the machine epsilon (lets call it m) 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 m = 1.
step 2 : if 1+m is less than or equal to 1, then go to step 5. otherwise go to step 3.
step 3: m = m/2
step 4: return to step 2.
step 5:m = 2*m
write you own M-file based on this algorithm to determine the machine epsilon. validate the results by running the built in file epsilon
我从网上找到一段:
%machine epsilonclc,clear
m = realmin;
while ((1+m) <= 1)
m = 2*m;
end
m
eps