我正在制作一个语法错误,有些我的语法如何导致python认为我正在编写+ .log一些在哪里?
请看一下代码并告诉我。
任何人都可以建议,一个可以用来代替解决这个算法的函数
import numpy as np
import sympy as sp
answer = 0
x = sp.Symbol('x')
y = sp.Symbol('y')
W = sp.Symbol('W')
R = sp.Symbol('R')
a = sp.Symbol('a')
n = sp.Symbol('n')
m = sp.Symbol('m')
O = sp.Symbol('O')
'''
answer = sp.solve(((((-1* (np.log(1+(x/R))))/(np.log(1+((10**6)/R))))+1)*(Os/((np.log(np.exp(1)+(x/a)**n))**m)))-W,x)
'''
answer = sp.solve(((((-1* (sp.log(1+(x/R))))/(sp.log(1+((10**6)/R))))+1)*(O/((sp.log(np.exp(1)+(x/a)**n))**m)))-W,x)
print(answer)
结果: OLD
line 15, in <module>
answer = sp.solve(((((-1* (np.log(1+(x/R))))/(np.log(1+((10**6)/R))))+1)*(Os/((np.log(np.exp(1)+(x/a)**n))**m)))-W,x)
AttributeError: 'Add' object has no attribute 'log'
Process finished with exit code 1
结果: 新
Continuum\Anaconda3\lib\site-packages\sympy\solvers\solvers.py", line 1414, in _solve
"\nNo algorithms are implemented to solve equation %s" % f)
NotImplementedError: multiple generators [log((x/a)**n + 54365636569181/20000000000000)**m, log(1 + x/R)]
No algorithms are implemented to solve equation O*(1 - log(1 + x/R)/log(1 + 1000000/R))*log((x/a)**n + 54365636569181/20000000000000)**(-m) - W
Process finished with exit code 1
答案 0 :(得分:2)
我认为您应该使用sp.log
代替np.log
。我运行你的代码,但似乎方程太复杂,没有实现任何算法来解决它。