Python numpy.arccosh()

Python numpy.arccosh()

numpy.arccosh() :这个数学函数帮助用户计算反双曲余弦,对所有Arr的元素进行计算。

语法 :

numpy.arccosh(arr, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, ufunc ‘arccosh’)

参数 :

arr : array_like
输入阵列。
out :[ndarray, optional] 一个储存结果的位置。
-> 如果提供,它必须有一个输入广播到的形状。
-> 如果没有提供或没有,将返回一个新分配的数组。
where : array_like, optional
值为True表示在该位置计算ufunc,值为False表示不考虑输出中的值。
**kwargs :允许向一个函数传递长度可变的关键字参数。当我们想在一个函数中处理命名参数时使用。

返回 :一个具有反双曲余弦的Arr的数组
为所有Arr即数组元素。

注意 :

2pi 弧度=360度
惯例是返回Arr的角度,其虚部位于[-pi, pi],实部位于[0, inf]。

**代码 #1 : **

# Python program explaining
# arccosh() function
  
import numpy as np
  
in_array = [2, 1, 10, 100]
print ("Input array : \n", in_array)
  
arccosh_Values = np.arccosh(in_array)
print ("\nInverse hyperbolic Cosine values : \n", arccosh_Values)
Python

输出 :

Input array : 
 [2, 1, 10, 100]

Inverse hyperbolic Cosine values : 
 [ 1.3169579   0.          2.99322285  5.29829237]
Python

代码#2:图形化表示

# Python program showing
# Graphical representation  
# of arccosh() function
%matplotlib inline 
import numpy as np
import matplotlib.pyplot as plt
in_array = np.linspace(1, np.pi, 18)
out_array1 = np.cos(in_array)
out_array2 = np.arccosh(in_array)
   
print("in_array : ", in_array)
print("\nout_array with cos : ", out_array1)
print("\nout_array with arccosh : ", out_array2)
#blue for numpy.cosh() 
# red for numpy.arccosh()
plt.plot(in_array, out_array1,
            color = 'blue', marker = ".")
               
plt.plot(in_array, out_array2,
            color = 'red', marker = "+")
               
plt.title("blue : numpy.cos() \nred : numpy.arccosh()")
plt.xlabel("X")
plt.ylabel("Y")
Python

输出 :

in_array :  [ 1.          1.12597604  1.25195208  1.37792812  1.50390415  1.62988019
  1.75585623  1.88183227  2.00780831  2.13378435  2.25976038  2.38573642
  2.51171246  2.6376885   2.76366454  2.88964058  3.01561662  3.14159265]

out_array with cos :  [ 0.54030231  0.43029566  0.31346927  0.19167471  0.0668423  -0.0590495
 -0.18400541 -0.30604504 -0.42323415 -0.53371544 -0.63573787 -0.72768451
 -0.80809809 -0.87570413 -0.92943115 -0.96842762 -0.99207551 -1.        ]

out_array with arccosh :  [ 0.          0.49682282  0.69574433  0.84411504  0.96590748  1.07053332
  1.16287802  1.24587516  1.32145434  1.39096696  1.45540398  1.51551804
  1.57189678  1.62500948  1.67523791  1.7228975   1.76825238  1.81152627]
Python

Python中的numpy.arccosh()

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册