使用 Python 計算雙曲餘弦
要計算雙曲餘弦,請在 Python Numpy 中使用 numpy.cosh() 方法。該方法等同於 1/2 * (np.exp(x) + np.exp(-x)) 和 np.cos(1j*x)。返回相應的雙曲餘弦值。如果 x 是標量,則這是一個標量。第一個引數 x 是輸入陣列。第二個和第三個引數是可選的。
第二個引數是一個 ndarray,結果儲存到其中。如果提供,則它必須具有輸入廣播到的形狀。如果沒有提供或為 None,則將返回一個新分配的陣列。
第三個引數是條件,它在輸入上進行廣播。在條件為 True 的位置,out 陣列將被設定為 ufunc 結果。在其他位置,out 陣列將保留其原始值。
步驟
首先,匯入必需的庫 −
import numpy as np
獲取雙曲三角餘弦度。找到 cosh −
print("\nResult...",np.cosh(np.pi*1j))找到 cosh 90 度 −
print("\nResult...",np.cosh(np.pi/2.))找到 cosh 60 度 −
print("\nResult...",np.cosh(np.pi/3.))
找到 cosh 45 度 −
print("\nResult...",np.cosh(np.pi/4.))找到 cosh 30 度 −
print("\nResult...",np.cosh(np.pi/6.))找到 cosh 0 度 −
print("\nResult...",np.cosh(0))示例
import numpy as np
# To compute the Hyperbolic cosine, use the numpy.cosh() method in Python Numpy
# The method is equivalent to 1/2 * (np.exp(x) + np.exp(-x)) and np.cos(1j*x).
print("Get the Trigonometric Hyperbolic cosine...")
# find cosh
print("\nResult...",np.cosh(np.pi*1j))
# finding cosh 90 degrees
print("\nResult...",np.cosh(np.pi/2.))
# finding cosh 60 degrees
print("\nResult...",np.cosh(np.pi/3.))
# finding cosh 45 degrees
print("\nResult...",np.cosh(np.pi/4.))
# finding cosh 30 degrees
print("\nResult...",np.cosh(np.pi/6.))
# finding cosh 0 degrees
print("\nResult...",np.cosh(0))輸出
Get the Trigonometric Hyperbolic cosine... Result... (-1+0j) Result... 2.5091784786580567 Result... 1.600286857702386 Result... 1.3246090892520057 Result... 1.1402383210764286 Result... 1.0
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP