使用 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