问题描述
使用浮点,已知二次公式不适用于b ^ 2 >> 4ac,因为如此处.
Using floating point, It is known that the quadratic formula does not work well for b^2>>4ac, because it will produce a loss of significance, as it is explained here.
我被要求寻找一种解决二次方程的更好的方法,我知道有这算法.还有其他更有效的公式吗?如何提出更好的公式?我试图以代数方式处理标准方程式,但没有任何结果.
I am asked to find a better way to solve quadratic equations, I know there is this algorithm. Are there any other formulas that work better? How can I come up with better formulas? I tried to algebraically manipulate the standard equation, without any results.
推荐答案
用于自动重新排列浮动内容的 Herbie 工具减少舍入误差的点表达式通常为解决此类错误提供了一个很好的起点.
The Herbie tool for automatically rearranging floating point expressions to reduce rounding error usually provides a good starting point for addressing errors like this.
在这种情况下,您可以使用在线演示查看二次方的正根的输出. ,以获取这些结果:
In this case you can see its output for the positive root of the quadratic using the online demo, to get these results:
这篇关于求解二次方程的数值稳定方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!