借助於sympy.harmonic()方法,我們可以在SymPy中找到調和數。
諧波(n)
第n次諧波數由-。
用法: harmonic(n)
參數:
n -它表示要計算的諧波數。
返回:返回nth諧波數。
範例1:
# import sympy
from sympy import *
n = 7
print("Value of n = {}".format(n))
# Use sympy.harmonic() method
nth_harmonic = harmonic(n)
print("Value of nth harmonic number : {}".format(nth_harmonic))
輸出:
Value of n = 7
Value of nth harmonic number : 363/140
諧波(n,m)
m階的n次廣義諧波數由-。
用法: harmonic(n, m)
參數:
n -它表示要計算的諧波數。
m -它表示諧波數的順序。
返回:返回m階的n次諧波。
範例2:
# import sympy
from sympy import *
n = 5
m = 2
print("Value of n = {} and m = {}".format(n, m))
# Use sympy.harmonic() method
nth_harmonic_poly = harmonic(n, m)
print("The nth harmonic number of order m : {}".format(nth_harmonic_poly))
輸出:
Value of n = 5 and m = 2
The nth harmonic number of order m : 5269/3600
相關用法
- 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()用法及代碼示例
注:本文由純淨天空篩選整理自rupesh_rao大神的英文原創作品 Python | sympy.harmonic() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。