求解具有一个变量的非线性方程 Python

Solve non linear equation with one variable Python

我正在尝试用 sympy 求解 python 中的以下等式。

13000*1.44**x =1000000

我试过了:

x = symbols('x', real=True) 
print(solveset(Eq(130000*1.44**x, 1000000), x))

现在这确实给出了:

ConditionSet(x, Eq(1.44**x - 100/13, 0), Complexes)

这个方程不适合solveset吗?我需要用 fsolve 解决这个问题吗?

提前致谢

你得到这个答案的原因是因为复数有无穷多个解。假设您只想要实数,请尝试使用 solveset_real:

from sympy.solvers.solveset import solveset_real

x = symbols('x', real=True)
print(solveset_real(Eq(130000*1.44**x, 1000000), x))

得到你

FiniteSet(2.74240747387354*log(100/13))