determining machine epsilon through steps
18 views (last 30 days)
Show older comments
I was doing my homework, and it asks me to write a code to determine epsilon. The question was to write code based on these steps
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 × ε
So I wrote,
e=1
while e+1>=1
e=e/2;
end
e=2*e;
however, not only looks like MATLAB doesn't want to process this, but also stopped working. I still can type codes but none of them actually getting registered. I just started to learn MATLAB, so I know almost nothing about it. Anyone can help me?
I'm using MATLAB through Citrix, by the way.
Accepted Answer
Guillaume
on 17 Sep 2014
You made a mistake with step 2, the condition to stop is: 1+e <= 1, thus the condition to continue is 1+e > 1. As it is your loop continues forever as when e equal epsilon, e+1 == 1
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!