sympy - 象征性地用浮动力求解方程

时间:2022-09-03 20:21:57

Using sympy, I define the symbols,

使用sympy,我定义符号,

a, b, c = sympy.symbols(['a', 'b', 'c'])

Then, when I try to solve the following system of equations,

然后,当我尝试解决以下方程组时,

sympy.solve([sympy.Eq(b - a**2.552 - c), sympy.Eq(a, 2)])

I get the solution,

我得到了解决方案,

[{b: c + 5.86446702875684, a: 2.00000000000000}]

But, when I try to solve,

但是,当我试图解决时,

sympy.solve([sympy.Eq(b - a**2.552 - c), sympy.Eq(b, 2)])

It just seems to keep running (for ~4hrs), with no solution. Any help would be appreciated!

它似乎继续运行(约4小时),没有解决方案。任何帮助,将不胜感激!

1 个解决方案

#1


5  

I don't know why but rational=False helps

我不知道为什么,但理性=假有帮助

sympy.solve([sympy.Eq(b - a**2.552 - c), sympy.Eq(b, 2)], rational=False)

see: sympy hangs when trying to solve a simple algebraic equation

看:当试图解决一个简单的代数方程时,sympy会挂起

#1


5  

I don't know why but rational=False helps

我不知道为什么,但理性=假有帮助

sympy.solve([sympy.Eq(b - a**2.552 - c), sympy.Eq(b, 2)], rational=False)

see: sympy hangs when trying to solve a simple algebraic equation

看:当试图解决一个简单的代数方程时,sympy会挂起