Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 sympy 的 atan2,对于某些值,它没有给我完整的数值评估,而是给了我一个 (value + pi)
from sympy import atan2 print(atan2(0.0037, -0.056))
给出以下输出:
-0.0659755361339305 + 圆周率
我希望代码给出没有“+ pi”的数字值,在本例中为 3.07402446387
mpmath 的 mpf 函数解决了这个问题,但在我的代码的其他部分给出了错误消息。还有另一种方法吗?
from sympy import atan2 print(atan2(0.0037, -0.056).evalf())
做你想要的。
from sympy import atan2 print(atan2(0.0037, -0.056).evalf(30))
为您提供 30 位精度的数值结果。