Question about accuracy of two different methods
Afficher commentaires plus anciens
Greetings,
I have a question about accuracy. I have mathmatically equivalent method 1 and method 2. Practically, the final diffference beteween vol and vol1 is 8.8818e-15. In my program, this tiny difference can be amplified. But I still need to use method 1 form to get results as method 2.
%Method 1:
vol = 6
for i = 1:5000
vol = vol + 18.3 * 1e-3 * 0.1;
end
%Method 2:
vol1 = 6 + 18.3 * 1e-3 * 0.1 * 5000;
Does anyone can help me to explain why these two methods are different? And how can I get accurate results to avoid this tiny difference to be amplified?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing 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!