AttributeError: 'Add' object has no attribute 'log' Python

AttributeError: 'Add' object has no attribute 'log' Python

我犯了语法错误,我的语法如何导致 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)

结果: 老

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

我认为你应该使用 sp.log 而不是 np.log。我 运行 你的代码,但似乎方程太复杂了,没有实现算法来解决它。