<p>我刚刚运行了您的代码,发现<code>fx(b)</code>和<code>fx(a)</code>是相同的值。所以当你计算<code>fx(b)</code>减去<code>fx(a)</code>你得到<code>0</code>
希望这有帮助。你知道吗</p>
<pre><code>Terminal -----------------------------------
Enter zeroes in approxiamtion in solution: 5
Enter upper limit for root: 5
Enter lower limit for root: 5
93.0
93.0
Traceback (most recent call last):
File "d:/PythonScripts/first_python_project/curso_python.py", line 13, in <module>
c = b - ((b - a)/(fx(b) - fx(a))) * fx(b)
ZeroDivisionError: float division by zero
</code></pre>
<p>添加更多:
当您达到较低的值时,<code>fx(b)</code>和<code>fx(a)</code>会变得非常相似。
像这样:</p>
<pre><code>Enter zeroes in approxiamtion in solution: 3
Enter upper limit for root: 5
Enter lower limit for root: 3
93.0
5.0
3.0, 5.0, 2.8863636363636362
2.614751596543952
93.0
5.0, 2.8863636363636362, 2.825218326106125
1.424401534793665
2.614751596543952
2.8863636363636362, 2.825218326106125, 2.7520503761266304
0.08317571970829363
1.424401534793665
2.825218326106125, 2.7520503761266304, 2.747512887487003
0.002935214303143141
0.08317571970829363
2.7520503761266304, 2.747512887487003, 2.747346905212986
6.43830337132556e-06
0.002935214303143141
2.747512887487003, 2.747346905212986, 2.747346540335565
5.002736003234531e-10
6.43830337132556e-06
2.747346905212986, 2.747346540335565, 2.747346540307211
1.7763568394002505e-15
5.002736003234531e-10
2.747346540335565, 2.747346540307211, 2.747346540307211
1.7763568394002505e-15
1.7763568394002505e-15
Traceback (most recent call last):
File "d:/PythonScripts/first_python_project/curso_python.py", line 13, in <module>
c = b - ((b - a)/(fx(b) - fx(a))) * fx(b)
ZeroDivisionError: float division by zero
</code></pre>