Write a Matlab program by using a while loop that finds the smallest positive number 2^m such that 1+x>1 in the machine.
Afficher commentaires plus anciens
m must be a negative integer. Technically from the way that my professor phrased it, shouldn't m be -infinity?
2 commentaires
OCDER
le 13 Août 2018
Theoretical math and computer math are slightly different. You might find that 1+2^m > 1 will fail. https://www.cs.drexel.edu/~introcs/Fa15/extras/Rounding/index.html
James Tursa
le 14 Août 2018
Modifié(e) : James Tursa
le 14 Août 2018
"... shouldn't m be -infinity?"
2^(-infinity) = 0, and 1+0 is not greater than 1. So, no, the way the professor phrased it, -infinity is not the answer.
Do as the professor instructed and write some code with a while loop to figure out the answer.
Réponses (1)
Vishal Chaudhary
le 17 Août 2018
Modifié(e) : Vishal Chaudhary
le 17 Août 2018
0 votes
Precision differs in MATLAB and theoretical calculation. So when you write while loop you will know the difference.
1 commentaire
James Tursa
le 17 Août 2018
We discourage providing complete answers to homework on this forum.
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!