使用find()
simpy模塊中的方法,我們可以在數學函數中找到子表達式(如果存在)。find()
方法返回數學函數中的子表達式。
Syntax:sympy.find(x)
Return:returns subexpression
代碼1:
借助以下示例,我們可以清楚地了解使用sympy.find()
方法,我們可以從給定的表達式計算子表達式。
# importing sympy library
from sympy import *
# taking symbols
x, y, z = symbols('x y z')
# calling find() method on expression
geek = (3 * x + log(3 * x) + sqrt((x + 1)**2 + x)).find(log)
print(geek)
輸出:
set([log(3*x)])
代碼2:
# importing sympy library
from sympy import *
# taking symbols
a, b = symbols('a b')
# calling find() method on expression
geek = (3 * a + b * log(a) + log(b) + log(a)*log(1 / b)).find(log)
print(geek)
輸出:
set([log(a), log(1/b), log(b)])
相關用法
- Python next()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python set()用法及代碼示例
- Python Decimal max()用法及代碼示例
- Python PIL ImageOps.fit()用法及代碼示例
- Python os.rmdir()用法及代碼示例
- Python sympy.det()用法及代碼示例
- Python Decimal min()用法及代碼示例
- Python os.readlink()用法及代碼示例
- Python os.writev()用法及代碼示例
- Python os.readv()用法及代碼示例
- Python PIL RankFilter()用法及代碼示例
- Python os.rename()用法及代碼示例
- Python os.sendfile()用法及代碼示例
注:本文由純淨天空篩選整理自Shivam_k大神的英文原創作品 Python | sympy.find() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。