本文介绍了计算中点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么在二分法中,最好是用下式来计算a和b之间的中点c:$ b $ pre code c = a +( b-a)/ 2.
而不是简单的:
c =(a + b)/ 2.
所有变量都是浮点数。
解决方案
这是为了避免中间计算中的任何潜在溢出/精度损失。
Why in the bisection method it is better to compute the midpoint c between a and b with
c = a + (b - a) / 2.
instead of the simpler:
c = (a + b) / 2.
all variables are floating points.
解决方案
it is to avoid any potential overflows / loss of precision in intermediate calculations.
这篇关于计算中点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!