有些背景,请参阅此问题.我在这个问题上遇到的主要问题已经解决了,有人建议我再向另一个人提出我遇到的第二个问题:
print cubic(1, 2, 3, 4) # Correct solution: about -1.65
...
if x > 0:
TypeError: no ordering relation is defined for complex numbers
print cubic(1, -3, -3, -1) # Correct solution: about 3.8473
if x > 0:
TypeError: no ordering relation is defined for complex numbers
Run Code Online (Sandbox Code Playgroud)
具有一个实根和两个复根的三次方程式正在接收错误,即使我使用了cmath模块并定义了多维数据集根函数来处理复数.为什么是这样?